Compare commits

...
15 Commits
Author SHA1 Message Date
safavimohadeseh78 a23950e17f docs: add AI team prompt and cursor guidelines 2026-11-18 10:13:32 +03:30
safavimohadeseh78 3a1269c30b fix(ui): center page loading spinner and use accent spin color
Apply shared app-page-content-loading layout and theme-aligned spin dots across the app.
2026-08-31 02:36:56 -04:00
MojtabaSoumi 6c56a409e5 1405/01/22-fix bugs in gift card 2026-04-11 17:53:21 +03:30
MojtabaSoumi f4572575d7 1405/01/20-add giftcard & discount 2026-04-09 14:05:21 +03:30
MojtabaSoumi 8833749f51 1405/01/20-add giftcard & discount 2026-04-09 13:40:54 +03:30
safavimohadeseh78 668becae9d add noghreh to category 2026-02-15 12:21:48 +03:30
MojtabaSoumi e5503f8864 1404/11/20-add inventory for product 2026-02-09 11:59:33 +03:30
safavimohadeseh78 e5a76193b7 add shemshParnia to products 2026-02-03 18:24:45 +03:30
MojtabaSoumi d4db3e4e95 1404/11/14-add upload image product 2026-02-03 16:57:39 +03:30
safavimohadeseh78 57dfb44396 solve bug of add product 2026-01-04 11:12:36 +03:30
safavimohadeseh78 6fb5bb763b show balance_gold/cash 2025-12-30 11:12:13 +03:30
safavimohadeseh78 9bf89cf938 change edit product 2025-11-18 13:32:12 +03:30
safavimohadeseh78 3eaeb7bc07 change edit product 2025-11-18 13:02:47 +03:30
safavimohadeseh78 6b918237fc add shemsh to category 2025-11-17 15:49:14 +03:30
safavimohadeseh78 15e3e3e6c1 6/8/1404 2025-10-28 18:38:01 +03:30
22 changed files with 2187 additions and 415 deletions
+177
View File
@@ -0,0 +1,177 @@
---
description: دستورالعمل اجباری AI — پروژه ابشوده/خانگی (توکن کم، پچ محدود)
alwaysApply: true
---
# دستورالعمل اجباری برای هوش مصنوعی — پروژه ابشوده / خانگی
این فایل را کامل به AI بده (Project Rules / Custom Instructions / System prompt).
هدف: **توکن کمتر، یادگیری پایدار، حل سریع اصل کار، بدون تغییر الکی.**
---
## ۱) با هر پرامپت کاربر — همین ترتیب
1. اصل قضیه را **یک خط** مشخص کن (یک باگ / یک UI / یک فیچر).
2. مسیر را از **نقشه و یادداشت** بگیر — کل ریپو را سرچ نکن.
3. فقط **۱ تا ۳ فایل** مربوط را باز/پچ کن.
4. تمام کن؛ جواب کوتاه بده.
5. یک خط **یادداشت بخش** بنویس (پایین ببین) تا دفعهٔ بعد فراموش نشود.
```
پرامپت → اصل کار → نقشه/یادداشت → Grep فقط همان پوشه → پچ محدود → یادداشت → تمام
```
### ممنوع (سوخت توکن)
- دوباره پیدا کردن فایلی که در نقشه/یادداشت هست
- explore / گشت سراسری برای «X کجاست؟»
- خواندن کل فایل بلند وقتی چند ده خط کافی است
- refactor یا «درست کردن» فایل‌های هم‌جوار بدون درخواست
- کپی پچ به سیستم/اپ دیگر «برای کامل بودن»
---
## ۲) محدودهٔ تغییر — حساس
- **فقط** همان چیزی که کاربر گفته؛ جای بی‌ربط را دست نزن.
- مبهم بود (هدف، اپ، برنچ، سیستم حسابداری) → **بپرس**؛ حدس نزن.
- روی **برنچ فعلی** بمان؛ checkout/merge به برنچ دیگر بدون اجازه ممنوع.
- هر زیرپروژه git جدا دارد؛ فقط همان ریپوی مربوط را عوض کن.
| کار | فقط این ریپو |
|-----|----------------|
| ادمین | `khaneghi_admin` |
| API / SQL | `khaneghi_server` |
| اپ کاربر | `khaneghi_user` + تم + `ghatreh_user` (هر سه اگر رفتاری است) |
| سوپرادمین | `controlpanel_server` / `controlpanel_user` |
| بورس مس | فقط با درخواست صریح |
---
## ۳) حسابداری — قانون سخت
سیستم‌ها **جدا** هستند: زرین (`zarin`) / ته‌حساب (`tahesab`) / پرگار (`pargar`).
1. اگر گفت حسابداری/سند/سینک مشتری و **نام نبرد** → اول بپرس کدام؟
2. تا جواب ندادی کد نزن و فایل سیستم دیگر را باز نکن.
3. پچ یک سیستم را به بقیه کپی نکن مگر در همان پیام صریح بگوید.
---
## ۴) یادگیری قوی — یادداشت بخش‌ها
هر کار تمام‌شده را در دفتر پروژه ثبت کن (اگر در این ریپو هست:
`.cursor/skills/abshode-domain-lookup/learned-notes.md`):
```
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
```
قبل از هر Grep سراسری: **یادداشت‌ها را بخوان.**
اگر مسیر آنجا بود، دوباره سرچ نکن.
---
## ۵) نقشهٔ سریع مسیرها
| موضوع | کجا |
|-------|-----|
| تنظیمات ادمین | `khaneghi_admin/src/pages/menuPages/configuration/` |
| فلگ منو از settings | `khaneghi_admin/src/utils/config.ts` |
| مشتریان | `khaneghi_admin/src/pages/menuPages/customers/` |
| همگام ته‌حساب | `…/accounting/components/TahesabCustomerSync.vue`, `TahesabWalletBulkSync.vue` |
| کد حساب همکار | `…/colleagueOrders/components/ColleagueAccountingAccounts.vue` |
| API ته‌حساب (فرانت) | `khaneghi_admin/src/api/tahesab.ts` |
| تنظیمات سرور / overlay سوپرادمین | `SuperAdminProgramSettingsOverlay`, `SettingsController` |
| deploy settings | `khaneghi_server/database/sql/deploy_settings_const.sql` — **value موجود را UPDATE نکن** |
| قیمت ویژه مشتری | `customer_special_pricing` + منوی `customers/special-price` |
نقشهٔ کامل‌تر (اگر موجود): `.cursor/skills/abshode-domain-lookup/project-map.md`
---
## ۶) فرانت — زیاد از Ant + UnoCSS + lodash استفاده کن
اولویت:
1. **BasicPacks** پروژه (دکمه/آیکون/اینپوت/مدال) اگر هست
2. **Ant Design Vue** (`a-button`, `a-input`, `a-table`, `a-spin`, `a-form`, …)
3. **UnoCSS** برای layout و فاصله (`flex`, `grid`, `gap-*`, `w-full`, `min-w-0`, `sm:`)
4. **lodash** برای داده (`get`, `debounce`, `cloneDeep`, `isEmpty`, …) — helper تکراری ننویس
5. CSS/`<style>` فقط وقتی utility کافی نیست (توکن تم، انیمیشن خاص)
```text
❌ button خام + CSS بزرگ برای layout
✅ Ant/Basic + کلاس‌های Uno روی تمپلیت + lodash برای منطق داده
```
- `BasicButton` را با `:deep` برای عوض کردن layout داخلی خراب نکن.
- رنگ: توکن تم؛ از `bg-primary/10` روی CSS variable پرهیز کن (اغلب می‌شکند).
---
## ۷) UI حرفه‌ای — عینک گرافیک‌کار
- هر بلوک جدید: **عنوان + یک خط راهنما** (این کار چیست / دکمه کی زده شود).
- **باکس‌بندی خوب است؛ فضای مرده بد است** — کارت عریض با محتوا فقط در یک گوشه ممنوع.
- یا `sm:grid-cols-2` / `flex` تا پر شود، یا عرض باکس را محدود کن.
- موبایل: اکشن **زیر** توضیح (`flex-col`).
- دسکتاپ: کنار یا ستون دوم پر (`sm:flex-row` / `sm:grid`).
- **نسبت سرچ و دکمه:**
- موبایل: سرچ `w-full`؛ بعد دکمه‌ها با عرض مساوی (`grid` / `1fr`).
- اینپوت باریک کنار دکمهٔ پهن در یک ردیف wrap = زشت → ممنوع.
- بنر گرادیان جیغ و دکمهٔ `block` تمام‌عرض الکی ممنوع مگر اکشن اصلی صفحه باشد.
- فشرده باش: `p-2.5` / `gap-2`؛ عدد و padding غول‌پیکر نگذار.
---
## ۸) مهندسی بک‌اند / فرانت — بدون باگ الکی
- یک مسئولیت در هر کامپوننت / متد / سرویس؛ خدا-فایل نساز.
- UI نازک؛ منطق سنگین در composable یا Service.
- Controller نازک → Service؛ SQL و business را قاطی نکن.
- خطا، خالی، timeout، دوبار کلیک / race را طراحی کن (`running` قفل، early return).
- الگوی همان پوشه را کپی کن؛ اختراع ساختار جدید نکن مگر لازم باشد.
- نام‌گذاری گویا؛ قرارداد API فرانت و بک یکی باشد.
---
## ۹) سوپرادمین / تنظیمات دسترسی
- کلیدهای دسترسی مشتری (`customer_special_pricing`, `has_page_*`, …) مال سوپرادمین‌اند؛ در پنل خانگی معمولاً فقط‌خواندنی.
- منوی وابسته به فلگ باید از `get_settings` / overlay زنده بیاید؛ کش کهنه برای این کلیدها مطلوب نیست.
- دکمهٔ بروزرسانی تنظیمات پیشرفته باید همگام زنده از سوپرادمین را هم بزند اگر فلگ منو می‌خواهد عوض شود.
---
## ۱۰) چک قبل از اتمام
- [ ] diff فقط به درخواست مربوط است؟
- [ ] سیستم حسابداری / اپ / برنچ اشتباه درگیر نشده؟
- [ ] اگر مبهم بود سؤال شد؟
- [ ] یادداشت یک‌خطی نوشته شد؟
- [ ] UI: راهنما + بدون فضای مرده + نسبت سرچ/دکمه درست؟
- [ ] Ant / Uno / lodash به‌جای reinvent؟
- [ ] جواب کوتاه است؛ توضیح اضافه نداری؟
---
## ۱۱) نمونهٔ رفتار درست / غلط
```text
❌ «همگام‌سازی مشتری خراب» → هر سه زرین/ته‌حساب/پرگار را عوض کند
✅ بپرسد کدام؟ بعد فقط همان
❌ UI یک کارت → کل صفحه accounting را redesign کند
✅ فقط همان کارت / همان فایل
❌ هر بار از صفر Grep مونوریپو
✅ learned-notes + project-map → مستقیم فایل
❌ CSS سفارشی ۵۰ خط برای flex ساده
✅ class="flex flex-col gap-2 sm:grid sm:grid-cols-2"
```
---
**پایان.** این سند را به‌روز نگه دار؛ نکات جدید حساس را همین‌جا یا در `learned-notes.md` اضافه کن.
@@ -0,0 +1,4 @@
# یادداشت‌های یادگیری — abshode-domain-lookup
فرمت هر خط:
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
+173
View File
@@ -0,0 +1,173 @@
# دستورالعمل اجباری برای هوش مصنوعی — پروژه ابشوده / خانگی
این فایل را کامل به AI بده (Project Rules / Custom Instructions / System prompt).
هدف: **توکن کمتر، یادگیری پایدار، حل سریع اصل کار، بدون تغییر الکی.**
---
## ۱) با هر پرامپت کاربر — همین ترتیب
1. اصل قضیه را **یک خط** مشخص کن (یک باگ / یک UI / یک فیچر).
2. مسیر را از **نقشه و یادداشت** بگیر — کل ریپو را سرچ نکن.
3. فقط **۱ تا ۳ فایل** مربوط را باز/پچ کن.
4. تمام کن؛ جواب کوتاه بده.
5. یک خط **یادداشت بخش** بنویس (پایین ببین) تا دفعهٔ بعد فراموش نشود.
```
پرامپت → اصل کار → نقشه/یادداشت → Grep فقط همان پوشه → پچ محدود → یادداشت → تمام
```
### ممنوع (سوخت توکن)
- دوباره پیدا کردن فایلی که در نقشه/یادداشت هست
- explore / گشت سراسری برای «X کجاست؟»
- خواندن کل فایل بلند وقتی چند ده خط کافی است
- refactor یا «درست کردن» فایل‌های هم‌جوار بدون درخواست
- کپی پچ به سیستم/اپ دیگر «برای کامل بودن»
---
## ۲) محدودهٔ تغییر — حساس
- **فقط** همان چیزی که کاربر گفته؛ جای بی‌ربط را دست نزن.
- مبهم بود (هدف، اپ، برنچ، سیستم حسابداری) → **بپرس**؛ حدس نزن.
- روی **برنچ فعلی** بمان؛ checkout/merge به برنچ دیگر بدون اجازه ممنوع.
- هر زیرپروژه git جدا دارد؛ فقط همان ریپوی مربوط را عوض کن.
| کار | فقط این ریپو |
|-----|----------------|
| ادمین | `khaneghi_admin` |
| API / SQL | `khaneghi_server` |
| اپ کاربر | `khaneghi_user` + تم + `ghatreh_user` (هر سه اگر رفتاری است) |
| سوپرادمین | `controlpanel_server` / `controlpanel_user` |
| بورس مس | فقط با درخواست صریح |
---
## ۳) حسابداری — قانون سخت
سیستم‌ها **جدا** هستند: زرین (`zarin`) / ته‌حساب (`tahesab`) / پرگار (`pargar`).
1. اگر گفت حسابداری/سند/سینک مشتری و **نام نبرد** → اول بپرس کدام؟
2. تا جواب ندادی کد نزن و فایل سیستم دیگر را باز نکن.
3. پچ یک سیستم را به بقیه کپی نکن مگر در همان پیام صریح بگوید.
---
## ۴) یادگیری قوی — یادداشت بخش‌ها
هر کار تمام‌شده را در دفتر پروژه ثبت کن (اگر در این ریپو هست:
`.cursor/skills/abshode-domain-lookup/learned-notes.md`):
```
- YYYY-MM-DD | موضوع | مسیر فایل(ها) | نکتهٔ ۱ خطی
```
قبل از هر Grep سراسری: **یادداشت‌ها را بخوان.**
اگر مسیر آنجا بود، دوباره سرچ نکن.
---
## ۵) نقشهٔ سریع مسیرها
| موضوع | کجا |
|-------|-----|
| تنظیمات ادمین | `khaneghi_admin/src/pages/menuPages/configuration/` |
| فلگ منو از settings | `khaneghi_admin/src/utils/config.ts` |
| مشتریان | `khaneghi_admin/src/pages/menuPages/customers/` |
| همگام ته‌حساب | `…/accounting/components/TahesabCustomerSync.vue`, `TahesabWalletBulkSync.vue` |
| کد حساب همکار | `…/colleagueOrders/components/ColleagueAccountingAccounts.vue` |
| API ته‌حساب (فرانت) | `khaneghi_admin/src/api/tahesab.ts` |
| تنظیمات سرور / overlay سوپرادمین | `SuperAdminProgramSettingsOverlay`, `SettingsController` |
| deploy settings | `khaneghi_server/database/sql/deploy_settings_const.sql` — **value موجود را UPDATE نکن** |
| قیمت ویژه مشتری | `customer_special_pricing` + منوی `customers/special-price` |
نقشهٔ کامل‌تر (اگر موجود): `.cursor/skills/abshode-domain-lookup/project-map.md`
---
## ۶) فرانت — زیاد از Ant + UnoCSS + lodash استفاده کن
اولویت:
1. **BasicPacks** پروژه (دکمه/آیکون/اینپوت/مدال) اگر هست
2. **Ant Design Vue** (`a-button`, `a-input`, `a-table`, `a-spin`, `a-form`, …)
3. **UnoCSS** برای layout و فاصله (`flex`, `grid`, `gap-*`, `w-full`, `min-w-0`, `sm:`)
4. **lodash** برای داده (`get`, `debounce`, `cloneDeep`, `isEmpty`, …) — helper تکراری ننویس
5. CSS/`<style>` فقط وقتی utility کافی نیست (توکن تم، انیمیشن خاص)
```text
❌ button خام + CSS بزرگ برای layout
✅ Ant/Basic + کلاس‌های Uno روی تمپلیت + lodash برای منطق داده
```
- `BasicButton` را با `:deep` برای عوض کردن layout داخلی خراب نکن.
- رنگ: توکن تم؛ از `bg-primary/10` روی CSS variable پرهیز کن (اغلب می‌شکند).
---
## ۷) UI حرفه‌ای — عینک گرافیک‌کار
- هر بلوک جدید: **عنوان + یک خط راهنما** (این کار چیست / دکمه کی زده شود).
- **باکس‌بندی خوب است؛ فضای مرده بد است** — کارت عریض با محتوا فقط در یک گوشه ممنوع.
- یا `sm:grid-cols-2` / `flex` تا پر شود، یا عرض باکس را محدود کن.
- موبایل: اکشن **زیر** توضیح (`flex-col`).
- دسکتاپ: کنار یا ستون دوم پر (`sm:flex-row` / `sm:grid`).
- **نسبت سرچ و دکمه:**
- موبایل: سرچ `w-full`؛ بعد دکمه‌ها با عرض مساوی (`grid` / `1fr`).
- اینپوت باریک کنار دکمهٔ پهن در یک ردیف wrap = زشت → ممنوع.
- بنر گرادیان جیغ و دکمهٔ `block` تمام‌عرض الکی ممنوع مگر اکشن اصلی صفحه باشد.
- فشرده باش: `p-2.5` / `gap-2`؛ عدد و padding غول‌پیکر نگذار.
---
## ۸) مهندسی بک‌اند / فرانت — بدون باگ الکی
- یک مسئولیت در هر کامپوننت / متد / سرویس؛ خدا-فایل نساز.
- UI نازک؛ منطق سنگین در composable یا Service.
- Controller نازک → Service؛ SQL و business را قاطی نکن.
- خطا، خالی، timeout، دوبار کلیک / race را طراحی کن (`running` قفل، early return).
- الگوی همان پوشه را کپی کن؛ اختراع ساختار جدید نکن مگر لازم باشد.
- نام‌گذاری گویا؛ قرارداد API فرانت و بک یکی باشد.
---
## ۹) سوپرادمین / تنظیمات دسترسی
- کلیدهای دسترسی مشتری (`customer_special_pricing`, `has_page_*`, …) مال سوپرادمین‌اند؛ در پنل خانگی معمولاً فقط‌خواندنی.
- منوی وابسته به فلگ باید از `get_settings` / overlay زنده بیاید؛ کش کهنه برای این کلیدها مطلوب نیست.
- دکمهٔ بروزرسانی تنظیمات پیشرفته باید همگام زنده از سوپرادمین را هم بزند اگر فلگ منو می‌خواهد عوض شود.
---
## ۱۰) چک قبل از اتمام
- [ ] diff فقط به درخواست مربوط است؟
- [ ] سیستم حسابداری / اپ / برنچ اشتباه درگیر نشده؟
- [ ] اگر مبهم بود سؤال شد؟
- [ ] یادداشت یک‌خطی نوشته شد؟
- [ ] UI: راهنما + بدون فضای مرده + نسبت سرچ/دکمه درست؟
- [ ] Ant / Uno / lodash به‌جای reinvent؟
- [ ] جواب کوتاه است؛ توضیح اضافه نداری؟
---
## ۱۱) نمونهٔ رفتار درست / غلط
```text
❌ «همگام‌سازی مشتری خراب» → هر سه زرین/ته‌حساب/پرگار را عوض کند
✅ بپرسد کدام؟ بعد فقط همان
❌ UI یک کارت → کل صفحه accounting را redesign کند
✅ فقط همان کارت / همان فایل
❌ هر بار از صفر Grep مونوریپو
✅ learned-notes + project-map → مستقیم فایل
❌ CSS سفارشی ۵۰ خط برای flex ساده
✅ class="flex flex-col gap-2 sm:grid sm:grid-cols-2"
```
---
**پایان.** این سند را به‌روز نگه دار؛ نکات جدید حساس را همین‌جا یا در `learned-notes.md` اضافه کن.
+1
View File
@@ -58,6 +58,7 @@ declare module '@vue/runtime-core' {
BaseTable: typeof import('./src/core/components/BaseTable/index.ts')['default'] BaseTable: typeof import('./src/core/components/BaseTable/index.ts')['default']
BaseTableOld: typeof import('./src/core/components/BaseTableOld/index.ts')['default'] BaseTableOld: typeof import('./src/core/components/BaseTableOld/index.ts')['default']
BasicCard: typeof import('./src/components/BasicCard.vue')['default'] BasicCard: typeof import('./src/components/BasicCard.vue')['default']
BasicImageUploader: typeof import('./src/components/BasicImageUploader.vue')['default']
BasicInfoItem: typeof import('./src/components/BasicInfoItem.vue')['default'] BasicInfoItem: typeof import('./src/components/BasicInfoItem.vue')['default']
BasicInput: typeof import('./src/components/BasicInput.vue')['default'] BasicInput: typeof import('./src/components/BasicInput.vue')['default']
BasicMainCard: typeof import('./src/components/BasicMainCard.vue')['default'] BasicMainCard: typeof import('./src/components/BasicMainCard.vue')['default']
+1 -1
View File
@@ -5,7 +5,7 @@ import pkg from './package.json'
const baseURL: string = 'https://ghatreh.gold/server/' const baseURL: string = 'https://ghatreh.gold/server/'
const uploadURL = `${baseURL}/site/file` const uploadURL = `${baseURL}admin/file`
const baseURLStorage = baseURL const baseURLStorage = baseURL
const prefixCls = 'hr-tamin' const prefixCls = 'hr-tamin'
const version = pkg.version const version = pkg.version
+14
View File
@@ -0,0 +1,14 @@
import type { TableInput } from '@core/type/baseTable'
import useAxios from '@core/utils/useAxios'
import type { Order } from '@/model/order'
import type { AddId, Customer } from '@/model/customer'
import type {Giftcard, GiftcardInput} from "@/model/giftCard";
export const getGiftCardTable = async (params: TableInput) =>
await useAxios.post<Array<Giftcard>>('/admin/giftcard/table', params)
export const createGiftCard = async (obj: GiftcardInput) =>
await useAxios.post<Giftcard>(`/admin/giftcard/generate`, obj)
+1 -1
View File
@@ -8,7 +8,7 @@ export const createProduct = async (obj: Customer) =>
await useAxios.post<AddId>(`/admin/product`, obj) await useAxios.post<AddId>(`/admin/product`, obj)
export const deleteCustomer = async (id: number) => await useAxios.delete(`/admin/product/${id}`) export const deleteCustomer = async (id: number) => await useAxios.delete(`/admin/product/${id}`)
export const updateCustomer = async (id: number, obj: Customer) => export const updateProduct = async (id: number, obj: Customer) =>
await useAxios.put<AddId>(`/admin/product/${id}`, obj) await useAxios.put<AddId>(`/admin/product/${id}`, obj)
export const getCustomerTable = async (params: TableInput) => export const getCustomerTable = async (params: TableInput) =>
+104
View File
@@ -0,0 +1,104 @@
<template>
<div class="clearfix">
<a-upload
v-model:file-list="fileList"
:action="props.url"
list-type="picture-card"
:headers="props.headers"
:maxCount="props.maxCount"
@preview="handlePreview"
@change="handleChange"
>
<div v-if="fileList.length < maxCount">
<plus-outlined/>
<div style="margin-top: 8px">بارگذاری</div>
</div>
</a-upload>
<a-modal :visible="previewVisible" :title="previewTitle" :footer="null" @cancel="handleCancel">
<img alt="example" style="width: 100%" :src="previewImage"/>
</a-modal>
</div>
</template>
<script setup lang="ts">
import {PlusOutlined} from '@ant-design/icons-vue';
import {defineComponent, ref} from 'vue';
import {message, type UploadChangeParam, type UploadProps} from 'ant-design-vue';
function getBase64(file: File) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
const previewVisible = ref(false);
const previewImage = ref('');
const previewTitle = ref('');
interface Prop {
url: string
multiple?: boolean
fileList?: Array<FileList>
maxCount?: number
headers?: any
}
const props = defineProps<Prop>()
//emits
const emits = defineEmits(['update:fileList', 'ok', 'delete'])
const fileList = computed({
get() {
return props.fileList || ([] as Array<FileList>)
},
set(value) {
emits('update:fileList', value)
}
})
const handleChange = (info: UploadChangeParam) => {
// console.log(info)
const status = info.file.status
if (status !== 'uploading') {
// console.log(info.file, info.fileList)
/*emits('ok', info.file.response.id)*/
}
if (status === 'done') {
// message.success(`${info.file.name} file uploaded successfully.`)
console.log(fileList)
emits('ok', info.file.response.id)
} else if (status === 'error') {
message.error(`خطا در بارگذاری فایل`)
} else if (status === 'removed') {
emits('delete', info.file.uid)
}
}
const handleCancel = () => {
previewVisible.value = false;
previewTitle.value = '';
};
const handlePreview = async (file: UploadProps['fileList'][number]) => {
if (!file.url && !file.preview) {
file.preview = (await getBase64(file.originFileObj)) as string;
}
previewImage.value = file.url || file.preview;
previewVisible.value = true;
previewTitle.value = file.name || file.url.substring(file.url.lastIndexOf('/') + 1);
}
</script>
<style>
/* you can make up upload button and sample style by using stylesheets */
.ant-upload-select-picture-card i {
font-size: 32px;
color: #999;
}
.ant-upload-select-picture-card .ant-upload-text {
margin-top: 8px;
color: #666;
}
</style>
@@ -76,9 +76,9 @@ const handleCancel = () => {
} }
const beforeUpload = (file: UploadProps['fileList'][number]) => { const beforeUpload = (file: UploadProps['fileList'][number]) => {
const isLt100k = file.size / 1024 / 1024 < 0.2 const isLt100k = file.size / 1024 / 1024 < 0.4
if (!isLt100k) { if (!isLt100k) {
message.error('حداکثر حجم بارگذاری 200 کیلو بایت میباشد') message.error('حداکثر حجم بارگذاری 400 کیلو بایت میباشد')
} }
return isLt100k return isLt100k
} }
+14 -2
View File
@@ -69,7 +69,19 @@
@apply px-1 py-3; @apply px-1 py-3;
} }
.ant-spin-dot-item,
.ant-spin-dot i {
background-color: var(--ant-primary-color, @primary-color) !important;
}
/* لودینگ محتوای صفحه — وسط ناحیه محتوا (موبایل و دسکتاپ یکسان) */
.app-page-content-loading {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
width: 100%;
min-height: min(52vh, 22rem);
padding: 2rem 1rem;
}
@@ -1,5 +1,5 @@
<template> <template>
<ASwitch v-model:checked="checked"></ASwitch> <ASwitch v-model:checked="checked" ></ASwitch>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
+8
View File
@@ -6,6 +6,14 @@ export function usePrice(price: number, digit = true, unit = 'ریال') {
return `${_price} ${unit}` return `${_price} ${unit}`
} }
export function usePriceWithoutType(price?: number, digit = true, unit = 'ریال') {
let _price = price?.toString()
if (digit) {
_price = _price?.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
return `${_price}`
}
export function useTowDecimal(num: string | number): string | number { export function useTowDecimal(num: string | number): string | number {
const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/) const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)
if (temp && temp.length > 0) return temp[0] if (temp && temp.length > 0) return temp[0]
+48
View File
@@ -0,0 +1,48 @@
export interface Giftcard {
id: number
customer_id: any
count: number
amount: number
total: number
unit: number
unique_code: any
created_at: string
sts: any
expiry_date: string
used_count: any
updated_at: string
description: string
sts_str: any
giftcardcodes: Giftcardcode[]
}
export interface Giftcardcode {
id: number
giftcard_id: number
code: string
sts: number
unit: number
amount: number
assigned_to: AssignedTo
used_at: string
expiry_date: string
created_at: string
updated_at: string
}
export interface AssignedTo {
id: number
name: string
mobile: string
}
export interface GiftcardInput {
mobile: string
name: string
count: number
amount: number
unit: string
expiry_date: string
description: string
code:string
use_once:boolean
}
+7 -3
View File
@@ -1,11 +1,11 @@
import type { User } from '@/model/user' import type {User} from '@/model/user'
import type { Wallet } from '@/model/wallet' import type {Wallet} from '@/model/wallet'
export interface AddId { export interface AddId {
id: number id: number
} }
export interface Product{ export interface Product {
id: number, id: number,
amount: number, amount: number,
percent_fee_buy: number, percent_fee_buy: number,
@@ -28,6 +28,9 @@ export interface Product{
weight: number weight: number
auto_open_at: string auto_open_at: string
auto_close_at: string auto_close_at: string
description: string
file_id: number | null
inventory: number
} }
export interface MethodePrices { export interface MethodePrices {
@@ -36,6 +39,7 @@ export interface MethodePrices {
price: number price: number
profit: number profit: number
} }
export interface SetActiveTime { export interface SetActiveTime {
auto_open_at: string auto_open_at: string
auto_close_at: string auto_close_at: string
+6 -4
View File
@@ -108,7 +108,7 @@
</div> </div>
</div> </div>
</BaseCard> </BaseCard>
<BaseCard class="h-full md:col-span-7"> <BaseCard class="h-full w-full md:col-span-7">
<ASpin :spinning="tarazLoading"> <ASpin :spinning="tarazLoading">
<div class="grid md:grid-cols-3 gap-3 mt-2"> <div class="grid md:grid-cols-3 gap-3 mt-2">
<div> <div>
@@ -199,12 +199,13 @@
</div> </div>
</ASpin> </ASpin>
</BaseCard> </BaseCard>
<BaseCard class="w-full md:w-none md:col-span-2"> <BaseCard class="w-full md:w-none md:col-span-2">
<div class="text-lg font-bold">تراز بدهی</div> <div class="text-lg font-bold">تراز بدهی</div>
<div ref="main" class="w-full aspect-square"></div> <div ref="main" class="w-full aspect-square"></div>
</BaseCard> </BaseCard>
<BaseCard class="md:col-span-5"> <BaseCard class="w-full md:col-span-5">
<div id="chart"> <div id="chart">
<div class="font-bold text-lg mt-2 text-center md:text-right mb-2">مقایسه قیمت ها</div> <div class="font-bold text-lg mt-2 text-center md:text-right mb-2">مقایسه قیمت ها</div>
<apexchart <apexchart
@@ -257,9 +258,10 @@
</div> </div>
</div> </div>
</BaseCard> </BaseCard>
<div class="md:col-span-7 md:grid gap-4">
<div class="md:col-span-7 w-full grid gap-4">
<BaseCard> <BaseCard>
<div class=" "> <div>
<div class="flex flex-col md:flex-row justify-between items-center"> <div class="flex flex-col md:flex-row justify-between items-center">
<div class="flex items-end"> <div class="flex items-end">
<div class="text-2xl font-bold ml-2">{{ usePrice(123456789123, true, '') }}</div> <div class="text-2xl font-bold ml-2">{{ usePrice(123456789123, true, '') }}</div>
@@ -0,0 +1,139 @@
<template>
<div>
<BasicShowContext title="لیست کارت های هدیه">
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
<template #extraHeader>
<div class="flex gap-2">
<BaseButton v-if="!customerId" type="primary" size="small" class="flex" @click="emits('add', 'gift')">
<div>افزودن کارت هدیه</div>
<BaseIcon icon="vuesax-linear:gift" Size="16px" />
</BaseButton>
<BaseButton v-if="!customerId" type="primary" size="small" class="flex" @click="emits('add' ,'code')">
<div>افزودن کد تخفیف</div>
<BaseIcon icon="vuesax-linear:discount-circle" Size="16px" />
</BaseButton>
</div>
</template>
<template #action="{ column, record }">
<div class="gap-2 flex justify-center">
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
<template #title>
<span>مشخصات</span>
</template>
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
</a-tooltip>
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('giftcardcodes', record)">
<template #title>
<div>کدهای {{record.unit==3?'تخفیف':'کارت هدیه'}}</div>
</template>
<Icon icon="vuesax-linear:document-text" color="#1890ff" />
</a-tooltip>
</div>
</template>
</BaseTable>
</BasicShowContext>
</div>
</template>
<script lang="tsx" setup>
import type { TableInput } from '@core/type/baseTable'
import useBaseTable from '@core/components/BaseTableOld/hooks/useBaseTable'
import Icon from '@core/components/BaseIcon/src/Icon.vue'
import { changeCustomerActivation, getCustomerTable } from '@/api/customer'
import { cols } from '../hooks/orderColumns'
import { useUserStore } from '@/store/userStore'
import { usePrefix } from '@core/composable/usePrefix'
import { message } from 'ant-design-vue'
import { getOrderTable } from '@/api/order'
import {getGiftCardTable} from "@/api/giftCard";
const [submit, reload] = useBaseTable()
/*const select = (val) => {
val.sts === 1 ? return ['1'] : ['2']
}*/
//emits
interface Prop {
customerId: number
}
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'giftcardcodes'])
const props = defineProps<Prop>()
const { prefixCls } = usePrefix('pophoverstatus')
//permission
function checkPermission(temp: string) {
const store = useUserStore()
return store.canAccess(temp)
}
//define table
const table = ref(null)
const tblProps = ref<any>({
columns: cols,
api: (params: TableInput) => {
if (props.customerId) {
params.filters = []
params.filters?.push({
field: "customer_id",
type: "text",
value: props.customerId,
cr: "and",
op: "eq",
hidden: false
})
}
return getGiftCardTable(params)
}
//bordered: true
})
const loading = ref<boolean>(false)
async function changeCustomerActivationFunction(id: number) {
try {
loading.value = true
await changeCustomerActivation(id)
reload()
message.success('تغییر وضعیت با موفقیت انجام شد')
} catch (e) {
console.error(e)
} finally {
loading.value = false
}
}
const fetch = () => {
// console.log('sss')
reload()
}
// const spinTable = (val: boolean) => {
// // console.log('sss')
// table?.value?.loading.value = val
// }
defineExpose({
fetch
// spinTable
})
</script>
<style lang="less">
@prefix: ~'@{prefixCls}-pophoverstatus';
.@{prefix} {
.ant-menu-rtl.ant-menu-inline,
.ant-menu-rtl.ant-menu-vertical {
border-left: none;
}
.ant-menu-item-only-child {
border-radius: @border-radius-base;
}
//bor
/* .ant-input-group-addon:first-child {
!* border: #d9d9d9 1px solid;
border-radius: 0 6px 6px 0;*!
}*/
}
</style>
@@ -0,0 +1,268 @@
import type { BaseTableColumn } from '@core/type/baseTable'
import { toJalali, toJalaliNoTime, toTime } from '@core/utils/useDataTime'
import CustomTag from '@/components/CustomTag.vue'
import { usePrice } from '@core/utils/usePrice'
/*import BudgetSelect from '@/components/BudgetSelect.vue'
import { useStaticApiListsStore } from '@/store/staticApisStore'
import type { FilterSelect } from '@/model/filterSelect'
import type { DocItem } from '@/model/docType'*/
//define store
//const store = useStaticApiListsStore()
//document types
/*let docTypes: DocItem[]*/
/*onMounted(async () => {
docTypes = await store.readyDocTypeList()
})
const filteredDocTypes: FilterSelect = docTypes?.map((x: DocItem) => {
return {
label: x.title,
value: x.id
}
})*/
export const cols: BaseTableColumn[] = [
{
title: 'ردیف',
dataIndex: 'id',
key: 'id',
filterable: false,
sortable: false,
customRender: (record: any) => {
return record.index + 1
}
},
{
title: 'کد ',
dataIndex: 'id',
key: 'id',
type: 'Number'
// className: 'column-money'
},
{
title: 'نوع کد',
dataIndex: 'unit',
key: 'unit',
filterable: false,
customRender: ({ record }) => {
switch (record.unit) {
case 2:
return (
<div class="flex justify-center">
<CustomTag textColor="#C53030" bgColor="#FECACA">
کارت هدیه طلایی
</CustomTag>
</div>
)
case 1:
return (
<div class="flex justify-center">
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
کارت هدیه ریالی
</CustomTag>
</div>
)
case 3:
return (
<div class="flex justify-center">
<CustomTag textColor="#377ef4" bgColor="#ccedff">
کد تخفیف
</CustomTag>
</div>
)
}
}
},
{
title: 'تعداد کد ها',
dataIndex: 'count',
key: 'count',
type: 'Number'
},
{
title: 'مقدار',
dataIndex: 'amount',
key: 'amount',
type: 'Text',
customRender: (record: any) => {
if (record.record.unit==3)
return `${record.text*100} درصد`
else if (record.record.unit==2)
return `${record.text} گرم`
else return'-'
}
},
{
title: 'مبلغ کل (ریال)',
dataIndex: 'total',
key: 'total',
type: 'Number',
customRender: (data) => {
if (data.record.unit==1)
return usePrice(data.record?.total ?? 0, true, '')
else
return '-'
}
},
{
title: 'کد یکتا',
dataIndex: 'unique_code',
key: 'unique_code',
type: 'Text'
},
{
title: 'تعداد استفاده شده',
dataIndex: 'used_count',
key: 'used_count',
type: 'Number'
},
{
title: 'نام پویش',
dataIndex: 'name',
key: 'name',
type: 'Text',
customRender: ({ record }) => {
return record.name ?? '-'
}
},
// {
// title: 'مشتری',
// dataIndex: 'customer.name',
// key: 'customer.name',
// type: 'Text',
// customRender: ({ record }) => {
// return record.customer?.name ?? '-'
// }
// },
// {
// title: 'شماره موبایل مشتری',
// dataIndex: 'customer.mobile',
// key: 'customer.mobile',
// type: 'Number',
// customRender: ({ record }) => {
// return record.customer?.mobile ?? '-'
// }
// },
{
title: 'توضیحات',
dataIndex: 'description',
key: 'description',
type: 'Text'
},
{
title: 'وضعیت',
dataIndex: 'sts',
key: 'sts',
filterable: false,
customRender: ({ record }) => {
switch (record.sts) {
case 1:
return (
<div class="flex justify-center">
<CustomTag textColor="#ca8a04" bgColor="#fef3c7">
{record.sts_str}
</CustomTag>
</div>
)
case 2:
return (
<div class="flex justify-center">
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
{record.sts_str}
</CustomTag>
</div>
)
default:
return (
<div class="flex justify-center">
<CustomTag textColor="#C53030" bgColor="#FECACA">
{record.sts_str}
</CustomTag>
</div>
)
}
}
},
{
title: 'تاریخ ثبت',
dataIndex: 'created_at',
key: 'created_at',
type: 'DateTime',
customRender: (record: any) => {
return toJalali(record.record.created_at)
}
},
{
title: 'تاریخ انقضا',
dataIndex: 'expiry_date',
key: 'expiry_date',
type: 'DateTime',
customRender: (record: any) => {
return toJalali(record.record.expiry_date)
}
},
/*{
title: 'نقش',
dataIndex: 'user_type_record',
key: 'user_type_record',
type: 'Select',
filterable: false,
sortable: false,
filterComponentProps: {
multiple: true
},
filterField: 'user_type_obj.id',
filterComponent: ReadyUserTypeSelect,
/!* customRender: (record: any) => {
return record.record.user_type_record?.value
}*!/
customRender: ({ record }) => {
const items = record.is_admin ? (
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
ادمین
</CustomTag>
) : (
record.user_type_obj.map((item: { title: any }, index: any) => {
if (item) {
return (
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
{item?.title}
</CustomTag>
)
}
})
)
return <div class="flex justify-center items-center gap-2">{items}</div>
}
},
{
title: 'حوزه',
dataIndex: 'section',
key: 'section'
},
{
title: 'شماره موبایل',
dataIndex: 'mobile',
type: 'Number',
key: 'mobile'
},
{
title: 'تاریخ ثبت',
dataIndex: 'created_at',
key: 'created_at',
type: 'DateTime',
customRender: (record: any) => {
return toJalaliNoTime(record.record.created_at)
}
},*/
{
title: 'عملیات',
dataIndex: 'action',
key: 'action',
slot: 'action',
fixed: 'right',
filterable: false
}
]
+708
View File
@@ -0,0 +1,708 @@
<template>
<div>
<BasicMainCard>
<div class="flex w-full h-full">
<tbl
ref="table"
class="w-full h-full"
@info="info"
@edit="edit"
@delete="deleteItem"
@add="add"
@giftcardcodes="showGiftCardCodes"
/>
<!-- <BasicMenu :menu="menu" width="13rem" @onChange="tabSelected" />
<component :is="selectedComponent" class="mr-5" />-->
<!-- <BasicShowContext title="پروژه ها"> <Search /> </BasicShowContext>-->
</div>
</BasicMainCard>
<BasicModal
v-model:visible="addGiftCardVisible"
width="30rem"
:title="`${editId ? 'ویرایش' : 'افزودن'} کارت هدیه یا کد تخفیف`"
@ok="ok"
:loading="loading"
@close="addGiftCardVisible = false"
>
<a-form :model="form" ref="formRef" autocomplete="off">
<div class="grid md:grid-cols-1 gap-4">
<!-- <a-form-item label="شماره موبایل مشتری" name="mobile" :rules="inputLenRules(11)">-->
<!-- <BasicInput-->
<!-- v-model:value="form.mobile"-->
<!-- type="tel"-->
<!-- placeholder="09123456789"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="نام پویش" name="name" >
<BasicInput
v-model:value="form.name"
placeholder="نام پویش"
/>
</a-form-item>
<a-form-item label="نوع کارت هدیه" name="unit" :rules="inputRules()">
<a-radio-group
v-model:value="form.unit"
button-style="solid"
>
<a-radio-button value="1">ریالی</a-radio-button>
<a-radio-button value="2">طلایی</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item label="کد یکبار مصرف" name="unit" :rules="inputRules()">
<ASwitch v-model:checked="form.use_once"
checked-children="بله"
un-checked-children="خیر">
</ASwitch>
</a-form-item>
<a-form-item label="تعداد کدها" name="count" :rules="inputRulesNumber()">
<BasicInput
v-model:value="form.count"
type="tel"
placeholder="تعداد کدهای کارت هدیه"
/>
</a-form-item>
<a-form-item
:label="`مقدار ${form.unit === '2' ? '(گرم)' : '(ریال)'}`"
name="amount"
:rules="inputRulesNumber()"
>
<BasicInput
v-model:value="form.amount"
:addon-before="form.unit === '2' ? 'گرم' : 'ریال'"
type="tel"
placeholder="مقدار کارت هدیه"
/>
</a-form-item>
<a-form-item v-if="!form.use_once" label="کد سفارشی" name="code">
<BasicInput
v-model:value="form.code"
placeholder="کد سفارشی"
/>
</a-form-item>
<a-form-item label="تاریخ انقضا" name="expiry_date" :rules="inputRules()">
<BaseDatePicker v-model:value="form.expiry_date" format="YYYY-MM-DD"/>
</a-form-item>
<a-form-item label="توضیحات" name="description">
<BasicTextArea
v-model:value="form.description"
place-holder="توضیحات اختیاری"
/>
</a-form-item>
</div>
</a-form>
</BasicModal>
<BasicModal
v-model:visible="addDiscountVisible"
width="30rem"
:title="`${editId ? 'ویرایش' : 'افزودن'} کد تخفیف`"
@ok="ok"
:loading="loading"
@close="addDiscountVisible = false"
>
<a-form :model="form" ref="formRef" autocomplete="off">
<div class="grid md:grid-cols-1 gap-4">
<!-- <a-form-item label="شماره موبایل مشتری" name="mobile" :rules="inputLenRules(11)">-->
<!-- <BasicInput-->
<!-- v-model:value="form.mobile"-->
<!-- type="tel"-->
<!-- placeholder="09123456789"-->
<!-- />-->
<!-- </a-form-item>-->
<a-form-item label="نام پویش" name="name" >
<BasicInput
v-model:value="form.name"
placeholder="نام پویش"
/>
</a-form-item>
<!-- <a-form-item label="نوع کارت هدیه" name="unit" :rules="inputRules()">-->
<!-- <a-radio-group-->
<!-- v-model:value="form.unit"-->
<!-- button-style="solid"-->
<!-- >-->
<!-- <a-radio-button value="1">ریالی</a-radio-button>-->
<!-- <a-radio-button value="2">طلایی</a-radio-button>-->
<!-- <a-radio-button value="3">کد تخفیف</a-radio-button>-->
<!-- </a-radio-group>-->
<!-- </a-form-item>-->
<a-form-item label="کد یکبار مصرف" name="unit" :rules="inputRules()">
<ASwitch v-model:checked="form.use_once"
checked-children="بله"
un-checked-children="خیر">
</ASwitch>
</a-form-item>
<a-form-item label="تعداد کدها" name="count" :rules="inputRulesNumber()">
<BasicInput
v-model:value="form.count"
type="tel"
placeholder="تعداد کدهای کارت هدیه"
/>
</a-form-item>
<a-form-item
label="درصد تخفیف"
name="amount"
:rules="inputRulesNumber()"
>
<BasicInput
v-model:value="form.amount"
addon-before="درصد"
type="tel"
placeholder="مقدار کارت هدیه"
/>
</a-form-item>
<a-form-item v-if="!form.use_once" label="کد سفارشی" name="code">
<BasicInput
v-model:value="form.code"
placeholder="کد سفارشی"
/>
</a-form-item>
<a-form-item label="تاریخ انقضا" name="expiry_date" :rules="inputRules()">
<BaseDatePicker v-model:value="form.expiry_date" format="YYYY-MM-DD"/>
</a-form-item>
<a-form-item label="توضیحات" name="description">
<BasicTextArea
v-model:value="form.description"
place-holder="توضیحات اختیاری"
/>
</a-form-item>
</div>
</a-form>
</BasicModal>
<BasicInfoModal
v-model:visible="userInfoVisible"
@close="userInfoVisible = false"
:title="infoParams.title"
:date="infoParams.date"
:time="infoParams.time"
:type="infoParams.type"
:name="infoParams.name"
:items="infoParams.items"
/>
<BasicModal
v-model:visible="giftCardCodesVisible"
width="80%"
title="لیست کدهای کارت هدیه"
custom-footer
@close="giftCardCodesVisible = false"
>
<template #footer>
<a-button @click="giftCardCodesVisible = false">بستن</a-button>
</template>
<a-table
:columns="giftCardCodesColumns"
:data-source="selectedGiftCardCodes"
:pagination="{ pageSize: 10 }"
row-key="id"
>
<template #bodyCell="{ column, record, index }">
<template v-if="column.key === 'index'">
{{ index + 1 }}
</template>
<template v-else-if="column.key === 'sts'">
<CustomTag
v-if="record.sts === 1"
textColor="#ca8a04"
bgColor="#fef3c7"
>
فعال
</CustomTag>
<CustomTag
v-else-if="record.sts === 2"
textColor="#25855A"
bgColor="#E3F4E9"
>
استفاده شده
</CustomTag>
<CustomTag
v-else
textColor="#C53030"
bgColor="#FECACA"
>
غیرفعال
</CustomTag>
</template>
<template v-else-if="column.key === 'unit'">
<CustomTag
v-if="record.unit === 2"
textColor="#C53030"
bgColor="#FECACA"
>
طلایی
</CustomTag>
<CustomTag
v-else
textColor="#25855A"
bgColor="#E3F4E9"
>
ریالی
</CustomTag>
</template>
<template v-else-if="column.key === 'amount'">
{{ record.amount }} {{ record.unit === 2 ? 'گرم' : 'ریال' }}
</template>
<template v-else-if="column.key === 'expiry_date'">
{{ record.expiry_date ? toJalali(record.expiry_date) : '-' }}
</template>
<template v-else-if="column.key === 'used_at'">
{{ record.used_at ? toJalali(record.used_at) : '-' }}
</template>
<template v-else-if="column.key === 'assigned_to_name'">
{{ record.assigned_to?.name ?? '-' }}
</template>
<template v-else-if="column.key === 'assigned_to_mobile'">
{{ record.assigned_to?.mobile ?? '-' }}
</template>
</template>
</a-table>
</BasicModal>
<BasicModal
v-model:visible="discountCodesVisible"
width="80%"
title="لیست کدهای تخفیف"
custom-footer
@close="discountCodesVisible = false"
>
<template #footer>
<a-button @click="discountCodesVisible = false">بستن</a-button>
</template>
<a-table
:columns="discountCodesColumns"
:data-source="selectedGiftCardCodes"
:pagination="{ pageSize: 10 }"
row-key="id"
>
<template #bodyCell="{ column, record, index }">
<template v-if="column.key === 'index'">
{{ index + 1 }}
</template>
<template v-else-if="column.key === 'sts'">
<CustomTag
v-if="record.sts === 1"
textColor="#ca8a04"
bgColor="#fef3c7"
>
فعال
</CustomTag>
<CustomTag
v-else-if="record.sts === 2"
textColor="#25855A"
bgColor="#E3F4E9"
>
استفاده شده
</CustomTag>
<CustomTag
v-else
textColor="#C53030"
bgColor="#FECACA"
>
غیرفعال
</CustomTag>
</template>
<template v-else-if="column.key === 'unit'">
<CustomTag
v-if="record.unit === 2"
textColor="#C53030"
bgColor="#FECACA"
>
طلایی
</CustomTag>
<CustomTag
v-else
textColor="#25855A"
bgColor="#E3F4E9"
>
ریالی
</CustomTag>
</template>
<template v-else-if="column.key === 'amount'">
{{ record.amount*100 }}
</template>
<template v-else-if="column.key === 'expiry_date'">
{{ record.expiry_date ? toJalali(record.expiry_date) : '-' }}
</template>
<template v-else-if="column.key === 'used_at'">
{{ record.used_at ? toJalali(record.used_at) : '-' }}
</template>
<template v-else-if="column.key === 'assigned_to_name'">
{{ record.assigned_to?.name ?? '-' }}
</template>
<template v-else-if="column.key === 'assigned_to_mobile'">
{{ record.assigned_to?.mobile ?? '-' }}
</template>
</template>
</a-table>
</BasicModal>
</div>
</template>
<script setup lang="ts">
// import BasicInfoModal from '@/components/BasicInfoModal'
import {inputLenRules, inputRules, inputRulesNumber} from '@/utils/inputRules'
import {useStaticApiListsStore} from '@/store/staticApisStore'
import {ref} from 'vue'
import tbl from './components/table.vue'
import type {FormInstance} from 'ant-design-vue'
import BasicInfoModal from '@/components/BasicInfoModal/index.vue'
import {message} from 'ant-design-vue/es'
import type {Info} from '@/components/BasicInfoModal/model/Info'
import {toJalaliNoTime, toTime} from '@core/utils/useDataTime'
import {confirmDeleteItem} from '@/utils/confirmModal'
import {cloneDeep} from 'lodash'
import type {Item} from '@/model/Item'
import type {Customer} from '@/model/customer'
import {createCustomer, deleteCustomer, getCustomersList, updateCustomer} from '@/api/customer'
import {usePrice} from '@core/utils/usePrice'
import type {Giftcard, Giftcardcode, GiftcardInput} from '@/model/giftCard'
import CustomTag from '@/components/CustomTag.vue'
import {toJalali} from '@core/utils/useDataTime'
import {createGiftCard} from '@/api/giftCard'
import dayjs from 'dayjs'
//loading
const loading = ref<boolean>(false)
//define store
const store = useStaticApiListsStore()
//define tbl
const table = ref(null)
const refreshTable = () => table?.value?.fetch()
//form
const form = ref<GiftcardInput>({
name: '',
count: undefined,
amount: undefined,
unit: '1',
code: '',
use_once: false,
expiry_date: '',
description: ''
})
const formRef = ref<FormInstance>()
//info
let infoParams = reactive<Info>({})
const giftCardCodesVisible = ref<boolean>(false)
const discountCodesVisible = ref<boolean>(false)
const selectedGiftCardCodes = ref<Giftcardcode[]>([])
const giftCardCodesColumns = [
{
title: 'ردیف',
key: 'index',
dataIndex: 'index'
},
{
title: 'کد',
dataIndex: 'code',
key: 'code'
},
{
title: 'نوع',
dataIndex: 'unit',
key: 'unit'
},
{
title: 'مقدار',
dataIndex: 'amount',
key: 'amount'
},
{
title: 'وضعیت',
dataIndex: 'sts',
key: 'sts'
},
{
title: 'تاریخ انقضا',
dataIndex: 'expiry_date',
key: 'expiry_date'
},
{
title: 'تاریخ استفاده',
dataIndex: 'used_at',
key: 'used_at'
},
{
title: 'نام کاربر اختصاص داده شده',
dataIndex: 'assigned_to.name',
key: 'assigned_to_name'
},
{
title: 'شماره موبایل کاربر اختصاص داده شده',
dataIndex: 'assigned_to.mobile',
key: 'assigned_to_mobile'
}
]
const discountCodesColumns = [
{
title: 'ردیف',
key: 'index',
dataIndex: 'index'
},
{
title: 'کد',
dataIndex: 'code',
key: 'code'
},
// {
// title: 'نوع',
// dataIndex: 'unit',
// key: 'unit'
// },
{
title: 'درصد',
dataIndex: 'amount',
key: 'amount'
},
{
title: 'وضعیت',
dataIndex: 'sts',
key: 'sts'
},
{
title: 'تاریخ انقضا',
dataIndex: 'expiry_date',
key: 'expiry_date'
},
{
title: 'تاریخ استفاده',
dataIndex: 'used_at',
key: 'used_at'
},
{
title: 'نام پویش',
dataIndex: 'name',
key: 'name'
},
// {
// title: 'شماره موبایل کاربر اختصاص داده شده',
// dataIndex: 'assigned_to.mobile',
// key: 'assigned_to_mobile'
// }
]
function info(val: Giftcard) {
// نمایش اطلاعات اصلی در BasicInfoModal
if (val.unit==3){
infoParams.title = 'اطلاعات کد تخفیف'
infoParams.name = val.name ?? '-'
// infoParams.type = val.customer?.mobile ?? '-'
infoParams.date = toJalaliNoTime(val.created_at)
infoParams.time = toTime(val.created_at)
infoParams.itemsTitle = 'اطلاعات کد تخفیف'
infoParams.items = [
{
key: 'کد',
value: val.id ?? '-'
},
{
key: 'تعداد کدها',
value: val.count ?? '-'
},
{
key: 'درصد تخفیف',
value: val.amount*100 ?? '-'
},
{
key: 'کد یکبار مصرف است؟',
value: val.use_once ? 'بله':'خیر'
},
{
key: 'کد یکتا',
value: val.unique_code ?? '-'
},
{
key: 'تعداد استفاده شده',
value: val.used_count ?? '-'
},
{
key: 'وضعیت',
value: val.sts_str ?? '-'
},
{
key: 'تاریخ ثبت',
value: toJalaliNoTime(val.created_at)
},
{
key: 'تاریخ انقضا',
value: toJalaliNoTime(val.expiry_date)
},
{
key: 'توضیحات',
value: val.description ?? '-'
}
]
}
else {
infoParams.title = 'اطلاعات کارت هدیه'
infoParams.name = val.name ?? '-'
// infoParams.type = val.customer?.mobile ?? '-'
infoParams.date = toJalaliNoTime(val.created_at)
infoParams.time = toTime(val.created_at)
infoParams.itemsTitle = 'اطلاعات کارت هدیه'
infoParams.items = [
{
key: 'کد',
value: val.id ?? '-'
},
{
key: 'نوع کارت هدیه',
value: val.unit === 2 ? 'طلایی' : 'ریالی'
},
{
key: 'تعداد کدها',
value: val.count ?? '-'
},
{
key: 'مقدار (گرم)',
value: val.amount ?? '-'
},
{
key: 'مبلغ کل (ریال)',
value: usePrice(val.total ?? 0)
},
{
key: 'کد یکتا',
value: val.unique_code ?? '-'
},
{
key: 'تعداد استفاده شده',
value: val.used_count ?? '-'
},
{
key: 'وضعیت',
value: val.sts_str ?? '-'
},
{
key: 'تاریخ ثبت',
value: toJalaliNoTime(val.created_at)
},
{
key: 'تاریخ انقضا',
value: toJalaliNoTime(val.expiry_date)
},
{
key: 'توضیحات',
value: val.description ?? '-'
}
]
}
userInfoVisible.value = true
}
function showGiftCardCodes(val: Giftcard) {
// نمایش کدها در مودال جداگانه
if (val.unit==3){
if (val.giftcardcodes && val.giftcardcodes.length > 0) {
selectedGiftCardCodes.value = val.giftcardcodes
discountCodesVisible.value = true
} else {
message.info('کد‌ی برای این تخفیف وجود ندارد')
}
}else {
if (val.giftcardcodes && val.giftcardcodes.length > 0) {
selectedGiftCardCodes.value = val.giftcardcodes
giftCardCodesVisible.value = true
} else {
message.info('کد کارت هدیه‌ای برای این کارت وجود ندارد')
}
}
}
//edit
let editId: number | undefined = undefined
async function edit(record: Giftcard) {
addGiftCardVisible.value = true
editId = record.id
form.value = {
name: record.customer?.name ?? '',
count: record.count,
amount: record.amount,
unit: record.unit.toString(),
expiry_date: record.expiry_date,
description: record.description ?? ''
}
}
//add
async function add(typeAdd: string) {
editId = undefined
resetData()
console.log(typeAdd)
if (typeAdd == "gift") {
addGiftCardVisible.value = true
} else if (typeAdd == "code") {
addDiscountVisible.value = true
form.value.unit = '3'
}
}
//reset data
const resetData = () => {
formRef.value?.resetFields()
form.value = {
name: '',
count: undefined,
amount: undefined,
unit: '1',
code: '',
use_once: false,
expiry_date: '',
description: ''
}
}
//delete
const deleteItem = (id: number) => confirmDeleteItem('کارت هدیه', id, deleteCustomer, refreshTable)
//add project modal
const addGiftCardVisible = ref<boolean>(false)
const addDiscountVisible = ref<boolean>(false)
const userInfoVisible = ref<boolean>(false)
//submit gift card
async function ok() {
formRef.value?.validateFields().then(async () => {
loading.value = true
try {
// تنظیم تاریخ انقضا به آخر همان روز (23:59:59) و تبدیل به میلادی
const formData = {...form.value}
if (formData.expiry_date) {
// تبدیل به میلادی و تنظیم به آخر روز
formData.expiry_date = dayjs(formData.expiry_date)
.calendar('gregory')
.endOf('day')
.format('YYYY-MM-DD HH:mm:ss')
}
await createGiftCard(formData)
message.success(`${addGiftCardVisible.value?'کارت هدیه':'کد تخفیف'} با موفقیت ثبت شد`)
addGiftCardVisible.value = false
addDiscountVisible.value=false
resetData()
refreshTable()
} catch (e) {
console.error(e)
message.error(`خطا در ثبت ${addGiftCardVisible.value?'کارت هدیه':'کد تخفیف'}`)
} finally {
loading.value = false
}
})
}
</script>
<style scoped></style>
+293 -240
View File
@@ -28,8 +28,9 @@
<Collapse class="grid grid-cols-1 gap-2" v-model:activeKey="activeKey_"> <Collapse class="grid grid-cols-1 gap-2" v-model:activeKey="activeKey_">
<BaseCollapse title="اطلاعات محصول" active-key="0" :actives="activeKey_"> <BaseCollapse title="اطلاعات محصول" active-key="0" :actives="activeKey_">
<template #content> <template #content>
<!-- <div class="flex justify-between h-full w-full">--> <!-- <div class="flex justify-between h-full w-full">-->
<div <div
v-if="form.group_type === '' || form.group_type !== 'آبشده'"
class="md:flex justify-between border-1 border-solid rounded-lg border-gray-200 p-2" class="md:flex justify-between border-1 border-solid rounded-lg border-gray-200 p-2"
> >
<div class="items-center"> <div class="items-center">
@@ -83,7 +84,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="md:flex justify-between p-2 border-1 border-solid rounded-lg border-gray-200 mt-2"> <div v-if="form.group_type === '' || form.group_type !== 'آبشده'"
class="md:flex justify-between p-2 border-1 border-solid rounded-lg border-gray-200 mt-2">
<div> <div>
<span class="ml-4">وزن :</span> <span class="ml-4">وزن :</span>
<a-radio-group v-model:value="weightOption" name="radioGroup" class=""> <a-radio-group v-model:value="weightOption" name="radioGroup" class="">
@@ -97,7 +99,7 @@
<BasicInput v-model:value="form.amount" type="number" /> <BasicInput v-model:value="form.amount" type="number" />
</div> </div>
<div class="mt-1 mr-4" v-if="form.amount && form.amount < 1 && 0 < form.amount"> <div class="mt-1 mr-4" v-if="form.amount && form.amount < 1 && 0 < form.amount">
معادل {{form.amount * 1000}} سوت معادل {{ form.amount * 1000 }} سوت
</div> </div>
</div> </div>
</div> </div>
@@ -122,19 +124,27 @@
keyName="value" keyName="value"
/> />
</a-form-item> </a-form-item>
<!-- <a-form-item v-if="weightOption === '1'" label="وزن به گرم" name="amount" :rules="inputRules()"> <a-form-item v-if="form?.group_type !== 'آبشده'"
label="تعداد موجودی" name="inventory" :rules="inputRules()">
<BasicInput v-model:value="form.inventory" type="number" />
</a-form-item>
<!-- <a-form-item v-if="weightOption === '1'" label="وزن به گرم" name="amount" :rules="inputRules()">
<BasicInput v-model:value="form.amount" type="number" /> <BasicInput v-model:value="form.amount" type="number" />
</a-form-item>--> </a-form-item>-->
<a-form-item label="کارمزد درصدی موقع خرید" name="percent_fee_buy" :rules="inputRules()"> <a-form-item v-if="form?.group_type !== 'آبشده'"
label="کارمزد درصدی موقع خرید" name="percent_fee_buy" :rules="inputRules()">
<BasicInput v-model:value="form.percent_fee_buy" type="number" /> <BasicInput v-model:value="form.percent_fee_buy" type="number" />
</a-form-item> </a-form-item>
<a-form-item label="هزینه نقدی موقع خرید" name="cash_fee_buy" :rules="inputRules()"> <a-form-item v-if="form?.group_type !== 'آبشده'"
label="هزینه نقدی موقع خرید" name="cash_fee_buy" :rules="inputRules()">
<BasicInput v-model:value="form.cash_fee_buy" type="number" /> <BasicInput v-model:value="form.cash_fee_buy" type="number" />
</a-form-item> </a-form-item>
<a-form-item label="کارمزد درصدی موقع فروش" name="percent_fee_sell" :rules="inputRules()"> <a-form-item v-if="form?.group_type !== 'آبشده'"
label="کارمزد درصدی موقع فروش" name="percent_fee_sell" :rules="inputRules()">
<BasicInput v-model:value="form.percent_fee_sell" type="number" /> <BasicInput v-model:value="form.percent_fee_sell" type="number" />
</a-form-item> </a-form-item>
<a-form-item label="هزینه نقدی موقع فروش" name="cash_fee_sell" :rules="inputRules()"> <a-form-item v-if="form?.group_type !== 'آبشده'"
label="هزینه نقدی موقع فروش" name="cash_fee_sell" :rules="inputRules()">
<BasicInput v-model:value="form.cash_fee_sell" type="number" /> <BasicInput v-model:value="form.cash_fee_sell" type="number" />
</a-form-item> </a-form-item>
<a-form-item label="زمان شروع فعال سازی" name="auto_open_at"> <a-form-item label="زمان شروع فعال سازی" name="auto_open_at">
@@ -144,7 +154,7 @@
placeholder="انتخاب زمان" placeholder="انتخاب زمان"
:defaultValue="dayjs('00:00:00', 'HH:mm:ss')" :defaultValue="dayjs('00:00:00', 'HH:mm:ss')"
/> />
<!-- <a-time-picker v-model:value="form.auto_open_at"/>--> <!-- <a-time-picker v-model:value="form.auto_open_at"/>-->
</a-form-item> </a-form-item>
<a-form-item label="زمان پایان فعال سازی" name="auto_close_at"> <a-form-item label="زمان پایان فعال سازی" name="auto_close_at">
<TimePicker <TimePicker
@@ -153,7 +163,10 @@
placeholder="انتخاب زمان" placeholder="انتخاب زمان"
:defaultValue="dayjs('00:00:00', 'HH:mm:ss')" :defaultValue="dayjs('00:00:00', 'HH:mm:ss')"
/> />
<!-- <a-time-picker v-model:value="form.auto_close_at"/>--> <!-- <a-time-picker v-model:value="form.auto_close_at"/>-->
</a-form-item>
<a-form-item label="توضیحات" name="description" >
<BasicTextArea v-model:value="form.description" />
</a-form-item> </a-form-item>
</div> </div>
</a-form> </a-form>
@@ -219,7 +232,7 @@
:bgColor="userInfo?.active ? '#E3F4E9' : '#FECACA'" :bgColor="userInfo?.active ? '#E3F4E9' : '#FECACA'"
class="font-bold px-6" class="font-bold px-6"
> >
{{ userInfo?.active ? 'فعال' : 'غیرفعال' }} {{ userInfo?.active ? "فعال" : "غیرفعال" }}
</CustomTag> </CustomTag>
</div> </div>
</div> </div>
@@ -261,7 +274,7 @@
:bgColor="userInfo?.trade_active === 1 ? '#E3F4E9' : '#FECACA'" :bgColor="userInfo?.trade_active === 1 ? '#E3F4E9' : '#FECACA'"
class="font-bold px-6" class="font-bold px-6"
> >
{{ userInfo?.trade_active === 1 ? 'مجاز' : 'غیر مجاز' }} {{ userInfo?.trade_active === 1 ? "مجاز" : "غیر مجاز" }}
</CustomTag> </CustomTag>
</BasicInfoItem> </BasicInfoItem>
<div class="col-span-4 grid grid-cols-2 gap-3"> <div class="col-span-4 grid grid-cols-2 gap-3">
@@ -308,7 +321,7 @@
<a-form-item label="مقدار شارژ " name="value" :rules="inputRules()"> <a-form-item label="مقدار شارژ " name="value" :rules="inputRules()">
<BasicInput addon-before="ریال" v-model:value="formCharge.value" type="price" /> <BasicInput addon-before="ریال" v-model:value="formCharge.value" type="price" />
<div v-show="formCharge.value > 10"> <div v-show="formCharge.value > 10">
معادل {{ usePrice(formCharge.value / 10, true, 'تومان') }} معادل {{ usePrice(formCharge.value / 10, true, "تومان") }}
</div> </div>
</a-form-item> </a-form-item>
<a-form-item label="علت شارژ " name="value" :rules="inputRules()"> <a-form-item label="علت شارژ " name="value" :rules="inputRules()">
@@ -352,125 +365,131 @@
<script setup lang="ts"> <script setup lang="ts">
// import BasicInfoModal from '@/components/BasicInfoModal' // import BasicInfoModal from '@/components/BasicInfoModal'
import { Collapse, FormItem, message, Textarea, Form, TimePicker } from "ant-design-vue"; import { Collapse, FormItem, message, Textarea, Form, TimePicker } from "ant-design-vue";
import { inputLenRules, inputRules } from '@/utils/inputRules' import { inputLenRules, inputRules } from "@/utils/inputRules";
import { useStaticApiListsStore } from '@/store/staticApisStore' import { useStaticApiListsStore } from "@/store/staticApisStore";
import { ref, watch } from 'vue' import { ref, watch } from "vue";
import tbl from './components/table.vue' import tbl from "./components/table.vue";
import type { FormInstance } from 'ant-design-vue' import type { FormInstance } from "ant-design-vue";
import BasicInfoModal from '@/components/BasicInfoModal/index.vue' import BasicInfoModal from "@/components/BasicInfoModal/index.vue";
import type { Info } from '@/components/BasicInfoModal/model/Info' import type { Info } from "@/components/BasicInfoModal/model/Info";
import { toJalali, toJalaliNoTime, toTime } from '@core/utils/useDataTime' import { toJalali, toJalaliNoTime, toTime } from "@core/utils/useDataTime";
import { confirmDeleteItem } from '@/utils/confirmModal' import { confirmDeleteItem } from "@/utils/confirmModal";
import { cloneDeep } from 'lodash' import { cloneDeep } from "lodash";
import type { Item } from '@/model/Item' import type { Item } from "@/model/Item";
import type { Customer } from '@/model/customer' import type { Customer } from "@/model/customer";
import { createProduct, deleteCustomer, updateCustomer } from "@/api/product"; import {createProduct, deleteCustomer, updateProduct} from "@/api/product";
import type { Charge } from '@/model/wallet' import type { Charge } from "@/model/wallet";
import customers from '@/router/routes/products' import customers from "@/router/routes/products";
import { chargeWallet } from '@/api/wallet' import { chargeWallet } from "@/api/wallet";
import { usePrice } from '@core/utils/usePrice' import { usePrice } from "@core/utils/usePrice";
import jalaliday from 'jalaliday' import jalaliday from "jalaliday";
import ordersTbl from '@/pages/menuPages/orders/components/table.vue' import ordersTbl from "@/pages/menuPages/orders/components/table.vue";
import transactionsTbl from '@/pages/menuPages/transactions/components/table.vue' import transactionsTbl from "@/pages/menuPages/transactions/components/table.vue";
import smsTbl from '@/pages/menuPages/sms/components/table.vue' import smsTbl from "@/pages/menuPages/sms/components/table.vue";
import FundsTable from '@/pages/menuPages/customers/base/components/fundsTable.vue' import FundsTable from "@/pages/menuPages/customers/base/components/fundsTable.vue";
import ReferralsTable from '@/pages/menuPages/customers/base/components/referralsTable.vue' import ReferralsTable from "@/pages/menuPages/customers/base/components/referralsTable.vue";
import type { Order } from '@/model/order' import type { Order } from "@/model/order";
import Icon from '@core/components/BaseIcon/src/Icon.vue' import Icon from "@core/components/BaseIcon/src/Icon.vue";
import type { MethodePrices, Product } from "@/model/product"; import type { MethodePrices, Product } from "@/model/product";
import IndexImageUploader from '@/components/ProductUploader/IndexImageUploader.vue' import IndexImageUploader from "@/components/ProductUploader/IndexImageUploader.vue";
import ProductImageUploader from '@/components/ProductUploader/ProductImageUploader.vue' import ProductImageUploader from "@/components/ProductUploader/ProductImageUploader.vue";
//tabs //tabs
const activeKey = ref('اطلاعات جامع') const activeKey = ref("اطلاعات جامع");
//loading //loading
const loading = ref<boolean>(false) const loading = ref<boolean>(false);
//define store //define store
const store = useStaticApiListsStore() const store = useStaticApiListsStore();
//define tbl //define tbl
const table = ref(null) const table = ref(null);
const orderTable = ref(null) const orderTable = ref(null);
const transactionTable = ref(null) const transactionTable = ref(null);
const smsTable = ref(null) const smsTable = ref(null);
const referralTable = ref(null) const referralTable = ref(null);
const fundTable = ref(null) const fundTable = ref(null);
const refreshTable = () => table?.value?.fetch() const refreshTable = () => table?.value?.fetch();
const refreshOrderTable = () => orderTable?.value?.fetch() const refreshOrderTable = () => orderTable?.value?.fetch();
const refreshTransactionTable = () => transactionTable?.value?.fetch() const refreshTransactionTable = () => transactionTable?.value?.fetch();
const refreshSMSTable = () => smsTable?.value?.fetch() const refreshSMSTable = () => smsTable?.value?.fetch();
const refreshReferralTable = () => referralTable?.value?.fetch() const refreshReferralTable = () => referralTable?.value?.fetch();
const refreshFundTable = () => fundTable?.value?.fetch() const refreshFundTable = () => fundTable?.value?.fetch();
const methodOption = ref<string>('1') const methodOption = ref<string>("1");
const weightOption = ref<string>('1') const weightOption = ref<string>("1");
const activeKey_ = ref(["0"]);
const ImageFileList = ref<Array<FileList>>([]);
const activeKey_ = ref(['0'])
const ImageFileList = ref<Array<FileList>>([])
function uploadedFile(id: number) { function uploadedFile(id: number) {
// console.log(id) // console.log(id)
let arr: number[] | undefined = form.value.image_ids let arr: number[] | undefined = form.value.image_ids;
arr?.push(id) arr?.push(id);
form.value.image_ids = arr form.value.image_ids = arr;
} }
function deleteFile() { function deleteFile() {
form.value.image_ids = ImageFileList?.value.map((x: FileList) => x.uid) form.value.image_ids = ImageFileList?.value.map((x: FileList) => x.uid);
} }
import BaseCollapse from '@/pages/menuPages/products/base/components/BaseCollapse.vue'
import BaseCollapse from "@/pages/menuPages/products/base/components/BaseCollapse.vue";
import { methodePrices } from "@/api/price"; import { methodePrices } from "@/api/price";
import { getAllPrices } from "@/api/dashboard"; import { getAllPrices } from "@/api/dashboard";
import dayjs from "dayjs"; import dayjs from "dayjs";
const ProductIndexImage = ref<Array<FileList>>([])
const ProductIndexImage = ref<Array<FileList>>([]);
function uploadedIndexFile(id: number) { function uploadedIndexFile(id: number) {
// console.log(id) // console.log(id)
form.value.original_image_id = id form.value.file_id = id;
}
function deleteIndexFile() {
form.value.original_image_id = null
form.value.original_image = null
ProductIndexImage.value = []
} }
let updateKey = ref<number>(0) function deleteIndexFile() {
form.value.file_id = null;
form.value.file_id = null;
ProductIndexImage.value = [];
}
let updateKey = ref<number>(0);
//role confirm items //role confirm items
const confirmItems: Array<Item> = [ const confirmItems: Array<Item> = [
{ {
value: 'بله', value: "بله",
key: true key: true
}, },
{ {
value: 'خیر', value: "خیر",
key: false key: false
} }
] ];
const customerItems: Array<Item> = [ const customerItems: Array<Item> = [
{ {
value: 'همکار', value: "همکار",
key: 1 key: 1
}, },
{ {
value: 'خانگی', value: "خانگی",
key: 2 key: 2
}, },
{ {
value: 'سرمایه گذار', value: "سرمایه گذار",
key: 3 key: 3
} }
] ];
//wallet //wallet
const showMoneyWalletCharge = ref<boolean>(false) const showMoneyWalletCharge = ref<boolean>(false);
const showGoldWalletCharge = ref<boolean>(false) const showGoldWalletCharge = ref<boolean>(false);
const userInfoOrderVisible = ref<boolean>(false) const userInfoOrderVisible = ref<boolean>(false);
//form //form
const form = ref<Partial<Product>>({ const form = ref<Partial<Product>>({
auto_close_at: dayjs('00:00:00', 'HH:mm:ss'), auto_close_at: dayjs("00:00:00", "HH:mm:ss"),
auto_open_at: dayjs('00:00:00', 'HH:mm:ss') auto_open_at: dayjs("00:00:00", "HH:mm:ss")
}) });
// const form = ref<Order>({ // const form = ref<Order>({
// direction: 1, // direction: 1,
@@ -482,63 +501,63 @@ const form = ref<Partial<Product>>({
// goldCash: undefined, // goldCash: undefined,
// goldValue: undefined // goldValue: undefined
// }) // })
const formCharge = ref<Charge>({}) const formCharge = ref<Charge>({});
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>();
const formChargeRef = ref<FormInstance>() const formChargeRef = ref<FormInstance>();
//info //info
let infoParams = reactive<Info>({}) let infoParams = reactive<Info>({});
function infoOrder(val: Order) { function infoOrder(val: Order) {
infoParams.name = val.customer.name infoParams.name = val.customer.name;
infoParams.type = val.customer.mobile infoParams.type = val.customer.mobile;
infoParams.date = toJalaliNoTime(val.created_at) infoParams.date = toJalaliNoTime(val.created_at);
infoParams.time = toTime(val.created_at) infoParams.time = toTime(val.created_at);
infoParams.itemsTitle = 'اطلاعات کاربری' infoParams.itemsTitle = "اطلاعات کاربری";
infoParams.items = [ infoParams.items = [
{ {
key: 'مقدار (گرم)', key: "مقدار (گرم)",
value: val.amount ?? '-' value: val.amount ?? "-"
}, },
{ {
key: 'قیمت هر گرم طلا برای مشتری (ریال)', key: "قیمت هر گرم طلا برای مشتری (ریال)",
value: usePrice(val.price ?? 0) ?? '-' value: usePrice(val.price ?? 0) ?? "-"
}, },
{ {
key: 'قیمت کل برای مشتری (ریال)', key: "قیمت کل برای مشتری (ریال)",
value: usePrice(val.total_price ?? 0) ?? '-' value: usePrice(val.total_price ?? 0) ?? "-"
}, },
{ {
key: '/قیمت هر گرم طلا بدون سود (ریال)', key: "/قیمت هر گرم طلا بدون سود (ریال)",
value: usePrice(val.price_original ?? 0) ?? '-' value: usePrice(val.price_original ?? 0) ?? "-"
}, },
{ {
key: 'قیمت کل بدون سود (ریال)', key: "قیمت کل بدون سود (ریال)",
value: usePrice(val.total_price_original ?? 0) ?? '-' value: usePrice(val.total_price_original ?? 0) ?? "-"
}, },
{ {
key: 'سود هر گرم (ریال)', key: "سود هر گرم (ریال)",
value: usePrice(val.fee ?? 0) ?? '-' value: usePrice(val.fee ?? 0) ?? "-"
}, },
{ {
key: 'سود کل (ریال)', key: "سود کل (ریال)",
value: usePrice(val.total_fee ?? 0) ?? '-' value: usePrice(val.total_fee ?? 0) ?? "-"
}, },
{ {
key: 'کد کاربری', key: "کد کاربری",
value: val.customer.id ?? '-' value: val.customer.id ?? "-"
}, },
{ {
key: 'شماره ملی', key: "شماره ملی",
value: val.customer.n_code ?? '-' value: val.customer.n_code ?? "-"
}, },
{ {
key: 'کارمزد ریالی', key: "کارمزد ریالی",
value: usePrice(val.service_charge_price ?? 0) value: usePrice(val.service_charge_price ?? 0)
}, },
{ {
key: 'کارمزد طلایی', key: "کارمزد طلایی",
value: val.service_charge ?? '-' + ' گرم' value: val.service_charge ?? "-" + " گرم"
}, },
/* { /* {
key: 'تاریخ تولد', key: 'تاریخ تولد',
@@ -549,230 +568,261 @@ function infoOrder(val: Order) {
value: val.customer.shop_name ?? '-' value: val.customer.shop_name ?? '-'
},*/ },*/
{ {
key: 'شماره تلفن', key: "شماره تلفن",
value: val.customer.phone_number ?? '-' value: val.customer.phone_number ?? "-"
}, },
{ {
key: 'نام استان', key: "نام استان",
value: val.customer.province ?? '-' value: val.customer.province ?? "-"
}, },
{ {
key: 'نام شهر', key: "نام شهر",
value: val.customer.city ?? '-' value: val.customer.city ?? "-"
} }
/* { /* {
key: 'نام چاپی', key: 'نام چاپی',
value: val.print_name ?? '-' value: val.print_name ?? '-'
}*/ }*/
] ];
userInfoOrderVisible.value = true userInfoOrderVisible.value = true;
} }
async function info(val: Customer) { async function info(val: Customer) {
activeKey.value = 'اطلاعات جامع' activeKey.value = "اطلاعات جامع";
userInfo.value = cloneDeep(val) userInfo.value = cloneDeep(val);
userInfoVisible.value = true userInfoVisible.value = true;
await nextTick(() => { await nextTick(() => {
loading.value = true loading.value = true;
refreshFundTable() refreshFundTable();
refreshReferralTable() refreshReferralTable();
refreshSMSTable() refreshSMSTable();
refreshTransactionTable() refreshTransactionTable();
refreshOrderTable() refreshOrderTable();
loading.value = false loading.value = false;
}) });
} }
//edit //edit
let editId: number | undefined = undefined let editId: number | undefined = undefined;
async function edit(record: Customer) { async function edit(record: Customer) {
addUserVisible.value = true addUserVisible.value = true;
editId = record.id editId = record.id;
const customForm = cloneDeep(record) const customForm = cloneDeep(record);
form.value = cloneDeep(customForm) form.value = cloneDeep(customForm);
form.value.auto_open_at = dayjs(customForm.auto_open_at, 'HH:mm:ss') form.value.auto_open_at = dayjs(customForm.auto_open_at, "HH:mm:ss");
form.value.auto_close_at = dayjs(customForm.auto_close_at, 'HH:mm:ss') form.value.auto_close_at = dayjs(customForm.auto_close_at, "HH:mm:ss");
// نمایش فایل موجود اگر وجود داشته باشد
const file = (record as any).file;
if (file && file.src) {
ProductIndexImage.value = [{
uid: `file-${file.id}`,
name: file.original_name || `index-image-${file.id}`,
url: file.src,
src: file.src,
status: 'done' as const
}] as any;
} else {
ProductIndexImage.value = [];
}
} }
//add //add
async function add() { async function add() {
loading.value = true loading.value = true;
editId = undefined editId = undefined;
// await store.getUsersList() // await store.getUsersList()
addUserVisible.value = true addUserVisible.value = true;
updateKey.value++ updateKey.value++;
resetData() resetData();
loading.value = false loading.value = false;
} }
async function walletMoneyCharge(val: Customer) { async function walletMoneyCharge(val: Customer) {
showMoneyWalletCharge.value = true showMoneyWalletCharge.value = true;
formCharge.value.customer_id = val.id formCharge.value.customer_id = val.id;
} }
async function walletGoldCharge(val: Customer) { async function walletGoldCharge(val: Customer) {
showGoldWalletCharge.value = true showGoldWalletCharge.value = true;
formCharge.value.customer_id = val.id formCharge.value.customer_id = val.id;
} }
async function chargeMoneyWallet() { async function chargeMoneyWallet() {
formChargeRef.value?.validateFields().then(async () => { formChargeRef.value?.validateFields().then(async () => {
try { try {
loading.value = true loading.value = true;
await chargeWallet(formCharge.value, 'money') await chargeWallet(formCharge.value, "money");
formCharge.value.value = undefined formCharge.value.value = undefined;
message.success('افزایش اعتبار با موفقیت انجام شد') message.success("افزایش اعتبار با موفقیت انجام شد");
showMoneyWalletCharge.value = false showMoneyWalletCharge.value = false;
} catch (e) { } catch (e) {
console.log(e) console.log(e);
} finally { } finally {
loading.value = false loading.value = false;
} }
}) });
} }
async function chargeGoldWallet() { async function chargeGoldWallet() {
formChargeRef.value?.validateFields().then(async () => { formChargeRef.value?.validateFields().then(async () => {
try { try {
loading.value = true loading.value = true;
await chargeWallet(formCharge.value, 'gold') await chargeWallet(formCharge.value, "gold");
formCharge.value.value = undefined formCharge.value.value = undefined;
message.success('افزایش اعتبار با موفقیت انجام شد') message.success("افزایش اعتبار با موفقیت انجام شد");
showMoneyWalletCharge.value = false showMoneyWalletCharge.value = false;
} catch (e) { } catch (e) {
console.log(e) console.log(e);
} finally { } finally {
loading.value = false loading.value = false;
} }
}) });
} }
//reset data //reset data
const resetData = () => { const resetData = () => {
formRef.value?.resetFields() formRef.value?.resetFields();
form.value = { form.value = {
unit: '', unit: "",
group_type: '', group_type: "",
amount: undefined, amount: undefined,
percent_fee_buy: 0, percent_fee_buy: 0,
cash_fee_buy: 0, cash_fee_buy: 0,
percent_fee_sell: 0, percent_fee_sell: 0,
cash_fee_sell: 0, cash_fee_sell: 0
} };
} ProductIndexImage.value = [];
ImageFileList.value = [];
};
//delete //delete
const deleteItem = (id: number) => confirmDeleteItem('کاربر', id, deleteCustomer, refreshTable) const deleteItem = (id: number) => confirmDeleteItem("کاربر", id, deleteCustomer, refreshTable);
//define selects //define selects
onMounted(async () => { onMounted(async () => {
loading.value = true loading.value = true;
// await getResponsible() // await getResponsible()
// await getQC() // await getQC()
// await getManager() // await getManager()
loading.value = false loading.value = false;
}) });
//add project modal //add project modal
const addUserVisible = ref<boolean>(false) const addUserVisible = ref<boolean>(false);
const userInfoVisible = ref<boolean>(false) const userInfoVisible = ref<boolean>(false);
const userInfo = ref<Customer>() const userInfo = ref<Customer>();
//submit user //submit user
async function ok() { async function ok() {
formRef.value?.validateFields().then(async () => { formRef.value?.validateFields().then(async () => {
// console.log('salam', form.value) // console.log('salam', form.value)
// return // return
loading.value = true
loading.value = true;
try { try {
if (methodOption.value === '1') delete form.value.reading_method if (methodOption.value === "1") delete form.value.reading_method;
else delete form.value.price else delete form.value.price;
if(weightOption.value === '2') if (weightOption.value === "2")
form.value.amount = 1 form.value.amount = 1;
form.value.auto_open_at = dayjs(form.value.auto_open_at).format('HH:mm:ss') const payload = cloneDeep(form.value);
form.value.auto_close_at = dayjs(form.value.auto_close_at).format('HH:mm:ss') payload.auto_open_at = dayjs(payload.auto_open_at).format("HH:mm:ss");
await methodePrices(form.value) payload.auto_close_at = dayjs(payload.auto_close_at).format("HH:mm:ss");
// await methodePrices();
if (editId) { if (editId) {
await updateCustomer(editId, form.value) await updateProduct(editId, payload);
} else { } else {
await createProduct(form.value) await createProduct(payload);
} }
addUserVisible.value = false
refreshTable() addUserVisible.value = false;
resetData() refreshTable();
message.success('عملیات با موفقیت انجام شد') message.success("عملیات با موفقیت انجام شد");
resetData();
// await getResponsible() // await getResponsible()
// await getQC() // await getQC()
// await getManager() // await getManager()
} catch (e) { } catch (e) {
console.error(e) console.error(e);
// message.error('خطا در بارگذاری اطلاعات') // message.error('خطا در بارگذاری اطلاعات')
} finally { } finally {
loading.value = false loading.value = false;
} }
}) });
} }
const result = { const result = {
title: '' title: ""
} };
const userStatus = (status: number) => { const userStatus = (status: number) => {
switch (status) { switch (status) {
case 0: case 0:
result.title = 'احراز هویت نشده' result.title = "احراز هویت نشده";
break break;
case 1: case 1:
result.title = 'احراز هویت شده توسط سامانه هوشمند' result.title = "احراز هویت شده توسط سامانه هوشمند";
break break;
case 2: case 2:
result.title = 'احراز هویت شده توسط کارشناس' result.title = "احراز هویت شده توسط کارشناس";
break break;
} }
return result return result;
} };
const unitItems: Array<Item> = [ const unitItems: Array<Item> = [
{ {
value: 'عدد', value: "عدد"
}, },
{ {
value: 'گرم', value: "گرم"
}, }
] ];
const categoryItems: Array<Item> = [ const categoryItems: Array<Item> = [
{ {
value: 'آبشده', value: "آبشده"
}, },
{ {
value: 'مکعب', value: "مکعب"
}, },
{ {
value: 'گوی', value: "گوی"
}, },
{ {
value: 'سکه', value: "سکه"
}, },
{ {
value: 'سکه پارسیان', value: "سکه پارسیان"
}, },
{ {
value: 'شمش ونوس', value: "شمش"
}, },
] {
value: "شمش ونوس"
},
{
value: "شمش پرنیا"
},
{
value: "نقره"
}
const data = ref<MethodePrices[]>([]) ];
const data = ref<MethodePrices[]>([]);
const fetchData = async () => { const fetchData = async () => {
try { try {
data.value = await methodePrices() data.value = await methodePrices();
} catch (err) { } catch (err) {
console.error(err) console.error(err);
} finally { } finally {
loading.value = false loading.value = false;
} }
} };
const pricesList = computed(() => { const pricesList = computed(() => {
return data.value.map((x) => { return data.value.map((x) => {
@@ -780,44 +830,47 @@ const pricesList = computed(() => {
id: `${x.name}`, id: `${x.name}`,
// id: x.id, // id: x.id,
name: `${x.name}(${usePrice(x.price)})` name: `${x.name}(${usePrice(x.price)})`
} };
}) });
}) });
onMounted(() => { onMounted(() => {
fetchData() fetchData();
}) });
const addPrice = () => { const addPrice = () => {
if (form.value.price) form.value.price = parseInt(form.value.price) + 10000 if (form.value.price) form.value.price = parseInt(form.value.price) + 10000;
else form.value.price = 0 + 10000 else form.value.price = 0 + 10000;
} };
const minusPrice = () => { const minusPrice = () => {
if (form.value.price) form.value.price = parseInt(form.value.price) - 10000 if (form.value.price) form.value.price = parseInt(form.value.price) - 10000;
else form.value.price = 0 - 10000 else form.value.price = 0 - 10000;
} };
import customParseFormat from 'dayjs/plugin/customParseFormat' import customParseFormat from "dayjs/plugin/customParseFormat";
import locale from 'ant-design-vue/es/date-picker/locale/fa_IR' import locale from "ant-design-vue/es/date-picker/locale/fa_IR";
dayjs.extend(customParseFormat)
dayjs.extend(customParseFormat);
const customLocale = ref({ const customLocale = ref({
...locale, ...locale,
lang: { lang: {
...locale.lang, ...locale.lang,
now: "اکنون", now: "اکنون",
ok: "ثبت", ok: "ثبت"
}, }
}) });
</script> </script>
<style scoped> <style scoped>
.reject { .reject {
color: #ff0000 !important; color: #ff0000 !important;
} }
.success { .success {
color: #008000 !important; color: #008000 !important;
} }
.method_style .ant-select-selector { .method_style .ant-select-selector {
width: 15rem !important; width: 15rem !important;
} }
@@ -1,7 +1,7 @@
import type {BaseTableColumn} from '@core/type/baseTable' import type {BaseTableColumn} from '@core/type/baseTable'
import {toJalaliNoTime, toTime} from '@core/utils/useDataTime' import {toJalaliNoTime, toTime} from '@core/utils/useDataTime'
import CustomTag from '@/components/CustomTag.vue' import CustomTag from '@/components/CustomTag.vue'
import {usePrice} from '@core/utils/usePrice' import { usePrice, usePriceWithoutType } from "@core/utils/usePrice";
/*import BudgetSelect from '@/components/BudgetSelect.vue' /*import BudgetSelect from '@/components/BudgetSelect.vue'
import { useStaticApiListsStore } from '@/store/staticApisStore' import { useStaticApiListsStore } from '@/store/staticApisStore'
import type { FilterSelect } from '@/model/filterSelect' import type { FilterSelect } from '@/model/filterSelect'
@@ -84,6 +84,40 @@ export const cols: BaseTableColumn[] = [
key: 'customer.name', key: 'customer.name',
type: 'Text' type: 'Text'
}, },
{
title: 'موجودی طلایی بعد تراکنش (گرم)',
dataIndex: 'balance_gold',
key: 'balance_gold',
type: 'Number',
customRender: ({record}) => {
return record.balance_gold > 0 ? (
<div class="flex justify-center">
<div class={'font-bold px-6 text-green'}>{record?.balance_gold ?? '_'}</div>
</div>
) : (
<div class="flex justify-center">
<div class={'font-bold px-6 text-red'}>{record?.balance_gold ?? '_'}</div>
</div>
)
}
},
{
title: 'موجودی ریالی بعد تراکنش (ریال)',
dataIndex: 'balance_cash',
key: 'balance_cash',
type: 'Number',
customRender: ({record}) => {
return record?.balance_cash > 0 ? (
<div class="flex justify-center">
<div class={'font-bold px-6 text-green'}>{usePriceWithoutType(record?.balance_cash) ?? '_'}</div>
</div>
) : (
<div class="flex justify-center">
<div class={'font-bold px-6 text-red'}>{usePriceWithoutType(record?.balance_cash) ?? '_'}</div>
</div>
)
}
},
{ {
title: 'مقدار طلا طی تراکنش (گرم)', title: 'مقدار طلا طی تراکنش (گرم)',
dataIndex: 'gold', dataIndex: 'gold',
+3 -15
View File
@@ -55,9 +55,9 @@
@close="confirmWeightVisible = false" @close="confirmWeightVisible = false"
> >
<div class=" bg-gray-100 rounded-lg p-2"> <div class=" bg-gray-100 rounded-lg p-2">
<div class="mb-4">برداشت فیزیکی ({{ confirmWithdraw.title }})</div> <div class="mb-4">برداشت فیزیکی ({{ confirmWithdraw?.title }})</div>
<div class="mb-4 mr-1"> به وزن ({{ confirmWithdraw.amount }})</div> <div class="mb-4 mr-1"> به وزن ({{ confirmWithdraw?.amount }})</div>
<div class="mb-4 mr-1"> و قیمت ({{ usePrice(confirmWithdraw.price ?? 0, true, '') }})</div> <div class="mb-4 mr-1"> و قیمت ({{ usePrice(confirmWithdraw?.price ?? 0, true, '') }})</div>
</div> </div>
</BasicModal> </BasicModal>
</div> </div>
@@ -261,18 +261,6 @@ function openWeight(val) {
confirmWeightVisible.value = true confirmWeightVisible.value = true
} }
function ok(i) {
try {
// await sendWeights()
message.success('با موفقیت ثبت شد')
} catch (e) {
// message.error('خطا در بارگذاری اطلاعات')
console.error(e)
} finally {
console.log()
}
}
</script> </script>
<style scoped></style> <style scoped></style>
+35
View File
@@ -0,0 +1,35 @@
import type { RouteRecordRaw } from 'vue-router'
const Orders: RouteRecordRaw = {
name: 'giftCard',
path: '/giftCard',
component: () => import('@core/layouts/BasicLayout.vue'),
redirect: { name: 'giftCardMain' },
meta: {
icon: 'vuesax-linear:gift',
permissionsKey: 'giftCard',
title: 'کارت هدیه و تخفیف',
disabled: false,
hideMenu: false,
hideChildren: true,
order: 7
},
children: [
{
name: 'giftCardMain',
path: '',
component: () => import('@/pages/menuPages/giftCards/index.vue'),
meta: {
permissionsKey: 'project',
icon: 'vuesax-linear:empty-wallet-time',
order: 3,
title: 'کارت هدیه و تخفیف',
disabled: false,
hideMenu: false
//hideChildren: false
}
}
]
}
export default Orders