feat: polish admin UI, phone login, and product details

Switch admin auth to mobile, restyle shell/login with Vuesax icons, and add product detail fields plus public product pages.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
S. Esmaeili
2026-10-22 17:18:17 +03:30
co-authored by Cursor
parent 789d224ea0
commit 49f30a96b1
54 changed files with 3632 additions and 574 deletions
+13 -1
View File
@@ -1,4 +1,4 @@
import type { MediaDto, SectionKey, SiteSections } from "@imen/shared";
import type { MediaDto, ProductAttribute, SectionKey, SiteSections } from "@imen/shared";
/** Shapes returned by the admin endpoints of the API */
@@ -45,6 +45,18 @@ export interface AdminProduct {
desc: string;
specs: string[];
variants: string[];
details: string;
brand: string;
origin: string;
sizes: string[];
standards: string[];
features: string[];
applications: string[];
attributes: ProductAttribute[] | null;
packaging: string;
minOrder: string;
seoTitle: string;
seoDescription: string;
imageId: number | null;
image: MediaDto | null;
sortOrder: number;
+49
View File
@@ -0,0 +1,49 @@
<script setup lang="ts">
/**
* Page shell inside the white panel:
* - optional sticky head (toolbar / filters)
* - body: scrolls by default, or locks height when `lockBody` (table fills + scrolls internally)
*/
defineProps<{ lockBody?: boolean }>();
</script>
<template>
<div class="ap">
<header v-if="$slots.head" class="ap__head">
<slot name="head" />
</header>
<div class="ap__body" :class="{ 'ap__body--locked': lockBody }">
<slot />
</div>
</div>
</template>
<style scoped>
.ap {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
overflow: hidden;
}
.ap__head {
flex-shrink: 0;
padding: 16px 16px 12px;
border-bottom: 1px solid #eef1f6;
background: #ffffff;
}
.ap__body {
flex: 1;
min-height: 0;
overflow: auto;
padding: 16px;
}
.ap__body--locked {
display: flex;
flex-direction: column;
overflow: hidden;
}
</style>
+4 -4
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { DeleteOutlined, PictureOutlined } from "@ant-design/icons-vue";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import type { MediaDto } from "@imen/shared";
import { ref } from "vue";
import MediaPicker from "./MediaPicker.vue";
@@ -17,15 +17,15 @@ const open = ref(false);
class="flex size-28 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-dashed border-gray-300 bg-gray-50"
>
<img v-if="url" :src="url" alt="" class="size-full object-contain" />
<PictureOutlined v-else class="text-2xl text-gray-300" />
<VuesaxIcon v-else name="gallery" :size="32" class="text-gray-300" />
</div>
<a-space direction="vertical">
<a-button @click="open = true">
<template #icon><PictureOutlined /></template>
<template #icon><VuesaxIcon name="gallery" :size="16" /></template>
{{ url ? "تغییر تصویر" : "انتخاب یا آپلود تصویر" }}
</a-button>
<a-button v-if="url && clearable" danger @click="emit('clear')">
<template #icon><DeleteOutlined /></template>
<template #icon><VuesaxIcon name="trash" :size="16" /></template>
حذف تصویر
</a-button>
</a-space>
+31
View File
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { ref, watch } from "vue";
/** Textarea where every non-empty line is one list item (for longer items than tags allow) */
const items = defineModel<string[]>({ required: true });
defineProps<{ placeholder?: string; rows?: number }>();
const parse = (text: string) =>
text
.split("\n")
.map((l) => l.trim())
.filter(Boolean);
// keep the raw text locally so blank lines and trailing newlines survive while typing
const text = ref(items.value.join("\n"));
watch(items, (v) => {
if (parse(text.value).join("\n") !== v.join("\n")) text.value = v.join("\n");
});
const onInput = () => {
items.value = parse(text.value);
};
</script>
<template>
<a-textarea
v-model:value="text"
:placeholder="placeholder"
:auto-size="{ minRows: rows ?? 3, maxRows: 14 }"
@change="onInput"
/>
</template>
+5 -5
View File
@@ -1,5 +1,5 @@
<script setup lang="ts" generic="T">
import { ArrowDownOutlined, ArrowUpOutlined, DeleteOutlined, PlusOutlined } from "@ant-design/icons-vue";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
/** Editable list: add, remove and reorder items; each item is rendered by the default slot */
const items = defineModel<T[]>({ required: true });
@@ -41,14 +41,14 @@ const add = () => {
</span>
<a-space :size="4">
<a-button size="small" :disabled="i === 0" title="بالا" @click="move(i, -1)">
<template #icon><ArrowUpOutlined /></template>
<template #icon><VuesaxIcon name="arrow-up" :size="16" /></template>
</a-button>
<a-button size="small" :disabled="i === items.length - 1" title="پایین" @click="move(i, 1)">
<template #icon><ArrowDownOutlined /></template>
<template #icon><VuesaxIcon name="arrow-down" :size="16" /></template>
</a-button>
<a-popconfirm title="این مورد حذف شود؟" ok-text="حذف" cancel-text="انصراف" @confirm="remove(i)">
<a-button size="small" danger title="حذف">
<template #icon><DeleteOutlined /></template>
<template #icon><VuesaxIcon name="trash" :size="16" /></template>
</a-button>
</a-popconfirm>
</a-space>
@@ -56,7 +56,7 @@ const add = () => {
<slot :item="item" :index="i" />
</div>
<a-button type="dashed" block :disabled="items.length >= max" @click="add">
<template #icon><PlusOutlined /></template>
<template #icon><VuesaxIcon name="add" :size="16" /></template>
{{ addLabel }}
</a-button>
</div>
+2 -2
View File
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { InboxOutlined } from "@ant-design/icons-vue";
import type { MediaDto, Paginated } from "@imen/shared";
import { message } from "ant-design-vue";
import { ref, watch } from "vue";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
/** Modal to upload a new image or pick one from the media library */
const open = defineModel<boolean>("open", { required: true });
@@ -102,7 +102,7 @@ async function upload(file: File) {
:show-upload-list="false"
:before-upload="upload"
>
<p class="ant-upload-drag-icon"><InboxOutlined /></p>
<p class="ant-upload-drag-icon"><VuesaxIcon name="document-upload" :size="40" /></p>
<p class="ant-upload-text">تصویر را اینجا رها کنید یا کلیک کنید</p>
<p class="ant-upload-hint">
JPG، PNG، WebP، AVIF یا GIF — حداکثر ۱۵ مگابایت. تصویر به‌صورت خودکار بهینه و به WebP تبدیل می‌شود.
+55 -7
View File
@@ -3,16 +3,64 @@ defineProps<{ title: string; subtitle?: string; back?: string }>();
</script>
<template>
<div class="mb-6 flex flex-wrap items-center justify-between gap-4">
<div class="flex items-center gap-3">
<RouterLink v-if="back" :to="back" class="text-gray-400 hover:text-gray-700" title="بازگشت">→</RouterLink>
<div>
<h1 class="text-xl font-bold text-gray-800">{{ title }}</h1>
<p v-if="subtitle" class="mt-1 text-sm text-gray-500">{{ subtitle }}</p>
<div class="page-header">
<div class="page-header__main">
<RouterLink v-if="back" :to="back" class="page-header__back" title="بازگشت">→</RouterLink>
<div class="min-w-0">
<h1 class="page-header__title">{{ title }}</h1>
<p v-if="subtitle" class="page-header__subtitle">{{ subtitle }}</p>
</div>
</div>
<div class="flex flex-wrap items-center gap-2">
<div v-if="$slots.default" class="page-header__actions">
<slot />
</div>
</div>
</template>
<style scoped>
.page-header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.page-header__main {
display: flex;
align-items: center;
gap: 10px;
min-width: 0;
}
.page-header__back {
color: #94a3b8;
text-decoration: none;
transition: color 0.15s ease;
}
.page-header__back:hover {
color: #334155;
}
.page-header__title {
margin: 0;
font-size: 18px;
font-weight: 700;
line-height: 1.3;
color: #0f172a;
}
.page-header__subtitle {
margin: 2px 0 0;
font-size: 13px;
color: #94a3b8;
}
.page-header__actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
</style>
+58
View File
@@ -0,0 +1,58 @@
<script setup lang="ts">
import { computed } from "vue";
import icons from "@/icons/vuesax-linear.json";
const props = withDefaults(
defineProps<{
/** Short name (`add`) or full key (`vuesax-linear:add`) */
name: string;
size?: number | string;
}>(),
{ size: 18 },
);
const pack = icons as Record<string, string>;
const svgHtml = computed(() => {
const key = props.name.startsWith("vuesax-linear:")
? props.name
: `vuesax-linear:${props.name}`;
const raw = pack[key];
if (!raw) return "";
return raw
.replace(/\swidth="24"/, "")
.replace(/\sheight="24"/, "")
.replace(/stroke="#[A-Fa-f0-9]{3,8}"/g, 'stroke="currentColor"')
.replace(/fill="(?!none)#[A-Fa-f0-9]{3,8}"/g, 'fill="currentColor"');
});
const box = computed(() =>
typeof props.size === "number" ? `${props.size}px` : props.size,
);
</script>
<template>
<span
class="vx-icon"
:style="{ width: box, height: box }"
:aria-hidden="true"
v-html="svgHtml"
/>
</template>
<style scoped>
.vx-icon {
display: inline-flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
line-height: 0;
color: inherit;
}
.vx-icon :deep(svg) {
width: 100%;
height: 100%;
display: block;
}
</style>
+5
View File
@@ -0,0 +1,5 @@
import { h, type VNode } from "vue";
import VuesaxIcon from "./VuesaxIcon.vue";
/** Render a Vuesax linear icon (for Ant menu `icon` factories, etc.) */
export const vx = (name: string, size = 18): VNode => h(VuesaxIcon, { name, size });
File diff suppressed because one or more lines are too long
+523 -74
View File
@@ -1,20 +1,8 @@
<script setup lang="ts">
import {
AppstoreOutlined,
DashboardOutlined,
ExportOutlined,
FileImageOutlined,
LayoutOutlined,
LogoutOutlined,
MailOutlined,
MenuOutlined,
ShoppingOutlined,
TeamOutlined,
UserOutlined,
} from "@ant-design/icons-vue";
import { ROLE_LABELS } from "@imen/shared";
import { computed, h, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import { useAuthStore } from "@/stores/auth";
import { SITE_URL } from "@/utils/format";
@@ -23,14 +11,18 @@ const route = useRoute();
const router = useRouter();
const drawer = ref(false);
/** Icon badge box + Vuesax glyph (keeps pre-swap menu structure) */
const menuIcon = (name: string) => () =>
h("span", { class: "admin-menu__icon" }, [h(VuesaxIcon, { name, size: 16 })]);
const items = computed(() => [
{ key: "dashboard", icon: () => h(DashboardOutlined), label: "داشبورد" },
{ key: "products", icon: () => h(ShoppingOutlined), label: "محصولات" },
{ key: "categories", icon: () => h(AppstoreOutlined), label: "دسته‌بندی‌ها" },
{ key: "sections", icon: () => h(LayoutOutlined), label: "بخش‌های سایت" },
{ key: "messages", icon: () => h(MailOutlined), label: "پیام‌های تماس" },
{ key: "media", icon: () => h(FileImageOutlined), label: "کتابخانه رسانه" },
...(auth.isAdmin ? [{ key: "users", icon: () => h(TeamOutlined), label: "کاربران" }] : []),
{ key: "dashboard", icon: menuIcon("element-3"), label: "داشبورد" },
{ key: "products", icon: menuIcon("bag-2"), label: "محصولات" },
{ key: "categories", icon: menuIcon("category"), label: "دسته‌بندی‌ها" },
{ key: "sections", icon: menuIcon("row-vertical"), label: "بخش‌های سایت" },
{ key: "messages", icon: menuIcon("sms"), label: "پیام‌های تماس" },
{ key: "media", icon: menuIcon("gallery"), label: "کتابخانه رسانه" },
...(auth.isAdmin ? [{ key: "users", icon: menuIcon("profile-2user"), label: "کاربران" }] : []),
]);
/** menu entry to highlight for nested pages (products/12 → products) */
@@ -41,11 +33,31 @@ const MENU_OF: Record<string, string> = {
"category-edit": "categories",
"section-edit": "sections",
};
const PAGE_TITLES: Record<string, string> = {
dashboard: "داشبورد",
products: "محصولات",
"product-new": "محصول جدید",
"product-edit": "ویرایش محصول",
categories: "دسته‌بندی‌ها",
"category-new": "دسته‌بندی جدید",
"category-edit": "ویرایش دسته‌بندی",
sections: "بخش‌های سایت",
"section-edit": "ویرایش بخش",
messages: "پیام‌های تماس",
media: "کتابخانه رسانه",
users: "کاربران",
profile: "حساب کاربری",
};
const selected = computed(() => {
const name = String(route.name ?? "");
return [MENU_OF[name] ?? name];
});
const pageTitle = computed(() => PAGE_TITLES[String(route.name ?? "")] ?? "پنل مدیریت");
const userInitial = computed(() => (auth.user?.name?.trim().charAt(0) || "ک").slice(0, 1));
const go = ({ key }: { key: string | number }) => {
drawer.value = false;
void router.push({ name: String(key) });
@@ -55,78 +67,515 @@ watch(() => route.fullPath, () => (drawer.value = false));
</script>
<template>
<a-layout class="min-h-screen">
<a-layout class="admin-shell">
<a-layout-sider
:width="232"
:width="248"
breakpoint="lg"
collapsed-width="0"
:trigger="null"
class="!hidden lg:!block"
style="background: #0b1224"
class="admin-sider !hidden lg:!block"
>
<div class="flex items-center gap-3 px-5 py-5">
<img src="/favicon.svg" alt="" class="size-8" />
<div class="leading-tight text-white">
<div class="font-bold">ایمن پیشگامان</div>
<div class="text-[11px] text-white/50">پنل مدیریت</div>
<div class="admin-sider__brand">
<span class="admin-sider__logo">
<img src="/logo.png" alt="" class="size-7 object-contain" />
</span>
<div class="leading-tight">
<div class="text-[14px] font-bold text-[#0f172a]">ایمن پیشگامان</div>
<div class="text-[10px] font-medium tracking-wide text-[#94a3b8]">پنل مدیریت</div>
</div>
</div>
<a-menu
theme="dark"
mode="inline"
:selected-keys="selected"
:items="items"
style="background: transparent; border: 0"
@click="go"
/>
<div class="admin-sider__nav">
<div class="admin-sider__label">منوی اصلی</div>
<a-menu
class="admin-menu"
mode="inline"
:selected-keys="selected"
:items="items"
@click="go"
/>
</div>
</a-layout-sider>
<a-drawer v-model:open="drawer" placement="right" :width="260" :body-style="{ padding: 0, background: '#0b1224' }" :closable="false">
<a-menu theme="dark" mode="inline" :selected-keys="selected" :items="items" style="background: transparent; border: 0" @click="go" />
<a-drawer
v-model:open="drawer"
placement="right"
:width="280"
:closable="false"
class="admin-drawer"
:body-style="{ padding: 0, background: '#ffffff' }"
>
<div class="admin-sider__brand">
<span class="admin-sider__logo">
<img src="/logo.png" alt="" class="size-7 object-contain" />
</span>
<div class="leading-tight">
<div class="text-[14px] font-bold text-[#0f172a]">ایمن پیشگامان</div>
<div class="text-[10px] font-medium text-[#94a3b8]">پنل مدیریت</div>
</div>
</div>
<div class="admin-sider__nav">
<div class="admin-sider__label">منوی اصلی</div>
<a-menu
class="admin-menu"
mode="inline"
:selected-keys="selected"
:items="items"
@click="go"
/>
</div>
</a-drawer>
<a-layout>
<a-layout-header
class="flex items-center justify-between gap-4 border-b border-gray-200 !bg-white !px-4 md:!px-6"
style="height: 60px; line-height: 60px"
>
<div class="flex items-center gap-3">
<a-button class="lg:!hidden" @click="drawer = true">
<template #icon><MenuOutlined /></template>
<a-layout-header class="admin-header">
<div class="admin-header__start">
<a-button class="admin-header__menu-btn lg:!hidden" @click="drawer = true">
<template #icon><VuesaxIcon name="menu" :size="18" /></template>
</a-button>
<a :href="SITE_URL" target="_blank" rel="noopener" class="flex items-center gap-1.5 text-sm text-gray-500 hover:text-[#ff5a00]">
<ExportOutlined />
مشاهده سایت
</a>
<div class="admin-header__crumb">
<span class="admin-header__crumb-kicker">پنل مدیریت</span>
<span class="admin-header__crumb-sep" aria-hidden="true">/</span>
<span class="admin-header__crumb-page">{{ pageTitle }}</span>
</div>
</div>
<a-dropdown placement="bottomLeft">
<a-button type="text" class="flex items-center gap-2">
<UserOutlined />
<span>{{ auth.user?.name }}</span>
<a-tag v-if="auth.user" class="!m-0" :color="auth.isAdmin ? 'orange' : 'blue'">
{{ ROLE_LABELS[auth.user.role] }}
</a-tag>
</a-button>
<template #overlay>
<a-menu>
<a-menu-item key="profile" @click="router.push({ name: 'profile' })">
<UserOutlined /> حساب کاربری
</a-menu-item>
<a-menu-item key="logout" danger @click="auth.logout()">
<LogoutOutlined /> خروج
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
<div class="admin-header__end">
<a
:href="SITE_URL"
target="_blank"
rel="noopener"
class="admin-header__site"
>
<VuesaxIcon name="export" :size="16" />
<span>مشاهده سایت</span>
</a>
<div class="admin-header__divider" aria-hidden="true" />
<a-dropdown placement="bottomLeft" :trigger="['click']">
<button type="button" class="admin-header__user">
<span class="admin-header__avatar">{{ userInitial }}</span>
<span class="admin-header__user-meta">
<span class="admin-header__user-name">{{ auth.user?.name }}</span>
<span v-if="auth.user" class="admin-header__user-role">
{{ ROLE_LABELS[auth.user.role] }}
</span>
</span>
<VuesaxIcon name="arrow-down" :size="12" class="admin-header__chevron" />
</button>
<template #overlay>
<a-menu class="admin-header__dropdown">
<a-menu-item key="profile" @click="router.push({ name: 'profile' })">
<VuesaxIcon name="user" :size="16" /> حساب کاربری
</a-menu-item>
<a-menu-divider />
<a-menu-item key="logout" danger @click="auth.logout()">
<VuesaxIcon name="logout" :size="16" /> خروج
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</div>
</a-layout-header>
<a-layout-content class="p-4 md:p-6">
<!-- keyed by path (not query) so /sections/hero → /sections/about gets a fresh page -->
<RouterView v-slot="{ Component, route: r }">
<component :is="Component" :key="r.path" />
</RouterView>
<a-layout-content class="admin-content">
<div class="admin-page">
<RouterView v-slot="{ Component, route: r }">
<component :is="Component" :key="r.path" />
</RouterView>
</div>
</a-layout-content>
</a-layout>
</a-layout>
</template>
<style scoped>
.admin-shell {
height: 100vh;
height: 100dvh;
overflow: hidden;
}
.admin-shell > :deep(.ant-layout) {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
overflow: hidden;
}
.admin-header {
position: sticky;
top: 0;
z-index: 20;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
height: 64px !important;
line-height: 1.3 !important;
padding-inline: 16px 20px !important;
background: rgba(255, 255, 255, 0.96) !important;
border-bottom: 1px solid #e8ecf2;
backdrop-filter: blur(10px);
box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}
.admin-content {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
overflow: hidden;
padding: 16px;
background: #f5f6fa;
box-sizing: border-box;
}
/* White panel locked to remaining viewport; pages manage their own inner scroll */
.admin-page {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
overflow: hidden;
background: #ffffff;
border: 1px solid #e8ecf2;
border-radius: 12px;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.admin-page > :deep(*) {
flex: 1;
min-width: 0;
min-height: 0;
}
/* Pages that don't use AdminPage still scroll inside the panel */
.admin-page > :deep(*:not(.ap)) {
overflow: auto;
padding: 16px;
box-sizing: border-box;
}
@media (min-width: 768px) {
.admin-header {
padding-inline: 24px !important;
}
}
.admin-header__start,
.admin-header__end {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.admin-header__menu-btn {
border-radius: 10px !important;
border-color: #e2e8f0 !important;
color: #475569 !important;
}
.admin-header__crumb {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.admin-header__crumb-kicker {
display: none;
font-size: 12px;
font-weight: 500;
color: #94a3b8;
}
@media (min-width: 640px) {
.admin-header__crumb-kicker {
display: inline;
}
}
.admin-header__crumb-sep {
display: none;
color: #cbd5e1;
}
@media (min-width: 640px) {
.admin-header__crumb-sep {
display: inline;
}
}
.admin-header__crumb-page {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 15px;
font-weight: 700;
color: #0f172a;
}
.admin-header__site {
display: inline-flex;
align-items: center;
gap: 8px;
height: 36px;
padding-inline: 14px;
border: 1px solid #e2e8f0;
border-radius: 999px;
background: #ffffff;
color: #475569;
font-size: 13px;
font-weight: 600;
text-decoration: none;
transition:
color 0.18s ease,
border-color 0.18s ease,
background 0.18s ease,
box-shadow 0.18s ease;
}
.admin-header__site:hover {
color: #e04f00;
border-color: #ffd0b5;
background: #fff7f2;
box-shadow: 0 2px 8px rgba(255, 90, 0, 0.08);
}
.admin-header__divider {
width: 1px;
height: 28px;
background: #e8ecf2;
}
.admin-header__user {
display: inline-flex;
align-items: center;
gap: 10px;
max-width: 260px;
height: 44px;
padding-block: 4px;
padding-inline: 4px 10px;
border: 1px solid #e8ecf2;
border-radius: 999px;
background: #f8fafc;
color: inherit;
cursor: pointer;
transition:
border-color 0.18s ease,
background 0.18s ease,
box-shadow 0.18s ease;
}
.admin-header__user:hover {
background: #ffffff;
border-color: #ffd0b5;
box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}
.admin-header__avatar {
display: inline-flex;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
flex-shrink: 0;
border-radius: 999px;
background: linear-gradient(135deg, #ff5a00, #ff8a3d);
color: #ffffff;
font-size: 14px;
font-weight: 700;
box-shadow: 0 2px 8px rgba(255, 90, 0, 0.28);
}
.admin-header__user-meta {
display: none;
flex-direction: column;
align-items: flex-start;
min-width: 0;
line-height: 1.25;
}
@media (min-width: 640px) {
.admin-header__user-meta {
display: flex;
}
}
.admin-header__user-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 140px;
font-size: 13px;
font-weight: 700;
color: #0f172a;
}
.admin-header__user-role {
font-size: 11px;
font-weight: 500;
color: #94a3b8;
}
.admin-header__chevron {
font-size: 10px;
color: #94a3b8;
}
.admin-sider {
height: 100vh !important;
height: 100dvh !important;
max-height: 100vh !important;
max-height: 100dvh !important;
position: sticky !important;
top: 0;
background: #ffffff !important;
/* content-facing edge (left in RTL) — continuous vertical rail */
border-inline-end: 1px solid #e8ecf2;
box-shadow: -4px 0 24px rgba(15, 23, 42, 0.04);
}
.admin-sider :deep(.ant-layout-sider-children) {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
overflow: hidden;
}
.admin-sider__brand {
display: flex;
flex-shrink: 0;
align-items: center;
gap: 10px;
height: 64px;
padding: 0 16px;
border-bottom: 1px solid #eef1f6;
box-sizing: border-box;
}
.admin-sider__logo {
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
border-radius: 10px;
background: #fff7f2;
border: 1px solid #ffe0cc;
box-shadow: 0 1px 2px rgba(255, 90, 0, 0.06);
}
.admin-sider__nav {
flex: 1;
min-height: 0;
height: calc(100vh - 64px);
height: calc(100dvh - 64px);
padding: 16px 12px 20px;
overflow-x: hidden;
overflow-y: auto;
}
.admin-sider__label {
margin: 0 8px 10px;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.06em;
color: #94a3b8;
}
.admin-menu {
background: transparent !important;
border: 0 !important;
}
.admin-menu :deep(.ant-menu-item) {
display: flex;
align-items: center;
height: 44px !important;
margin: 0 0 6px !important;
padding-inline: 12px !important;
border: 1px solid transparent !important;
border-radius: 12px !important;
color: #475569 !important;
font-weight: 500;
line-height: 44px !important;
transition:
background 0.2s ease,
color 0.2s ease,
border-color 0.2s ease,
box-shadow 0.2s ease;
}
.admin-menu :deep(.ant-menu-item-icon),
.admin-menu :deep(.ant-menu-item .anticon) {
display: inline-flex !important;
align-items: center;
justify-content: center;
width: auto !important;
height: auto !important;
margin-inline-end: 0 !important;
font-size: 0 !important;
background: transparent !important;
box-shadow: none !important;
}
.admin-menu :deep(.admin-menu__icon) {
display: inline-flex !important;
align-items: center;
justify-content: center;
width: 30px;
height: 30px;
margin-inline-end: 10px;
border-radius: 9px;
background: #f1f5f9;
color: #64748b;
transition:
background 0.2s ease,
color 0.2s ease,
box-shadow 0.2s ease;
}
.admin-menu :deep(.admin-menu__icon .vx-icon) {
width: 16px !important;
height: 16px !important;
background: transparent !important;
box-shadow: none !important;
color: inherit;
}
.admin-menu :deep(.ant-menu-item:hover) {
background: #f8fafc !important;
color: #0f172a !important;
border-color: #eef1f6 !important;
}
.admin-menu :deep(.ant-menu-item:hover .admin-menu__icon) {
background: #e8eef7;
color: #475569;
}
.admin-menu :deep(.ant-menu-item-selected) {
background: #fff7f2 !important;
border-color: #ffd7bf !important;
color: #c2410c !important;
font-weight: 700;
box-shadow: 0 4px 14px rgba(255, 90, 0, 0.1);
}
.admin-menu :deep(.ant-menu-item-selected .admin-menu__icon) {
background: #ff5a00 !important;
color: #ffffff !important;
box-shadow: 0 4px 10px rgba(255, 90, 0, 0.32);
}
.admin-menu :deep(.ant-menu-item-selected::after) {
display: none !important;
}
</style>
+7 -14
View File
@@ -1,15 +1,8 @@
<script setup lang="ts">
import {
ArrowDownOutlined,
ArrowUpOutlined,
DeleteOutlined,
EditOutlined,
ExportOutlined,
PlusOutlined,
} from "@ant-design/icons-vue";
import { message } from "ant-design-vue";
import { onMounted, ref } from "vue";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import type { AdminCategory } from "@/api/types";
import PageHeader from "@/components/PageHeader.vue";
import { faNumber, SITE_URL } from "@/utils/format";
@@ -68,7 +61,7 @@ onMounted(load);
<PageHeader title="دسته‌بندی‌ها" subtitle="ترتیب دسته‌ها همان ترتیب نمایش در سایت است">
<RouterLink :to="{ name: 'category-new' }">
<a-button type="primary">
<template #icon><PlusOutlined /></template>
<template #icon><VuesaxIcon name="add" :size="16" /></template>
دسته جدید
</a-button>
</RouterLink>
@@ -99,20 +92,20 @@ onMounted(load);
<template v-else-if="column.key === 'order'">
<a-space :size="4">
<a-button size="small" :disabled="index === 0" @click="move(index, -1)">
<template #icon><ArrowUpOutlined /></template>
<template #icon><VuesaxIcon name="arrow-up" :size="16" /></template>
</a-button>
<a-button size="small" :disabled="index === rows.length - 1" @click="move(index, 1)">
<template #icon><ArrowDownOutlined /></template>
<template #icon><VuesaxIcon name="arrow-down" :size="16" /></template>
</a-button>
</a-space>
</template>
<template v-else-if="column.key === 'actions'">
<a-space :size="4">
<RouterLink :to="{ name: 'category-edit', params: { id: record.id } }">
<a-button size="small"><template #icon><EditOutlined /></template></a-button>
<a-button size="small"><template #icon><VuesaxIcon name="edit-2" :size="16" /></template></a-button>
</RouterLink>
<a :href="`${SITE_URL}/categories/${record.slug}`" target="_blank" rel="noopener">
<a-button size="small" title="مشاهده در سایت"><template #icon><ExportOutlined /></template></a-button>
<a-button size="small" title="مشاهده در سایت"><template #icon><VuesaxIcon name="export" :size="16" /></template></a-button>
</a>
<a-popconfirm
title="این دسته حذف شود؟"
@@ -121,7 +114,7 @@ onMounted(load);
@confirm="remove(record as AdminCategory)"
>
<a-button size="small" danger :disabled="record.productCount > 0" :title="record.productCount > 0 ? 'ابتدا محصولات این دسته را حذف یا جابه‌جا کنید' : 'حذف'">
<template #icon><DeleteOutlined /></template>
<template #icon><VuesaxIcon name="trash" :size="16" /></template>
</a-button>
</a-popconfirm>
</a-space>
+2 -2
View File
@@ -1,11 +1,11 @@
<script setup lang="ts">
import { SaveOutlined } from "@ant-design/icons-vue";
import { categoryInputSchema, type MediaDto } from "@imen/shared";
import { message } from "ant-design-vue";
import { computed, onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import type { z } from "zod";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import type { AdminCategoryDetail } from "@/api/types";
import FormField from "@/components/FormField.vue";
import IconSelect from "@/components/IconSelect.vue";
@@ -108,7 +108,7 @@ onMounted(load);
<template>
<PageHeader :title="id ? `ویرایش دسته: ${model.name}` : 'دسته جدید'" back="/categories">
<a-button type="primary" :loading="saving" @click="save">
<template #icon><SaveOutlined /></template>
<template #icon><VuesaxIcon name="save-2" :size="16" /></template>
ذخیره
</a-button>
</PageHeader>
+2 -2
View File
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { PlusOutlined } from "@ant-design/icons-vue";
import { type DashboardDto, MESSAGE_STATUS_LABELS } from "@imen/shared";
import { message } from "ant-design-vue";
import { onMounted, ref } from "vue";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import PageHeader from "@/components/PageHeader.vue";
import { activityLabel, faNumber, jalali } from "@/utils/format";
@@ -22,7 +22,7 @@ onMounted(async () => {
<PageHeader title="داشبورد" subtitle="خلاصه وضعیت محتوای سایت">
<RouterLink :to="{ name: 'product-new' }">
<a-button type="primary">
<template #icon><PlusOutlined /></template>
<template #icon><VuesaxIcon name="add" :size="16" /></template>
محصول جدید
</a-button>
</RouterLink>
+174 -21
View File
@@ -1,16 +1,16 @@
<script setup lang="ts">
import { LockOutlined, MailOutlined } from "@ant-design/icons-vue";
import { loginSchema } from "@imen/shared";
import { ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import FormField from "@/components/FormField.vue";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import { useZodForm } from "@/composables/useZodForm";
import { useAuthStore } from "@/stores/auth";
const auth = useAuthStore();
const router = useRouter();
const route = useRoute();
const { model, validate, handleError } = useZodForm(loginSchema, { email: "", password: "" });
const { model, validate, handleError } = useZodForm(loginSchema, { phone: "", password: "" });
const loading = ref(false);
async function submit() {
@@ -30,26 +30,179 @@ async function submit() {
</script>
<template>
<div class="flex min-h-screen items-center justify-center bg-[#0b1224] p-4">
<div class="w-full max-w-sm rounded-2xl bg-white p-8 shadow-2xl">
<div class="mb-8 text-center">
<img src="/favicon.svg" alt="" class="mx-auto size-12" />
<h1 class="mt-4 text-xl font-bold text-gray-800">پنل مدیریت ایمن پیشگامان</h1>
<p class="mt-1 text-sm text-gray-500">برای ادامه وارد شوید</p>
<div class="login-page relative flex min-h-screen overflow-hidden text-[#edede6]">
<!-- atmosphere -->
<div class="pointer-events-none absolute inset-0 bg-[#0b1224]" />
<div class="login-grid pointer-events-none absolute inset-0 opacity-50" />
<div
class="pointer-events-none absolute -start-24 top-1/4 size-[420px] rounded-full bg-[#ff5a00]/15 blur-[120px]"
/>
<div
class="pointer-events-none absolute -end-16 bottom-0 size-[360px] rounded-full bg-[#ffb800]/10 blur-[100px]"
/>
<div class="login-tape pointer-events-none absolute bottom-0 end-0 z-10 h-48 w-1.5 opacity-70" />
<div class="login-noise pointer-events-none absolute inset-0 z-[5]" />
<div
class="relative z-10 mx-auto grid w-full max-w-[1120px] flex-1 items-center gap-10 px-5 py-12 md:px-8 lg:grid-cols-12 lg:gap-16"
>
<!-- form column -->
<div class="login-fade-3 lg:col-span-6">
<div
class="login-panel w-full max-w-md border border-[#2a3d63]/70 bg-[#1a2744]/80 p-7 backdrop-blur-md md:p-8 lg:me-auto"
>
<div class="mb-7 text-center">
<div class="font-mono text-[10px] tracking-[0.28em] text-[#8e9ab0]">SIGN IN</div>
<h2 class="mt-2 text-xl font-bold text-[#edede6]">ورود به پنل</h2>
<p class="mt-1.5 text-sm text-[#8e9ab0]">شماره موبایل و رمز عبور خود را وارد کنید</p>
</div>
<a-form class="login-form" layout="vertical" @submit.prevent="submit">
<FormField path="phone" label="شماره موبایل">
<a-input
v-model:value="model.phone"
size="large"
class="ltr-input"
autocomplete="tel"
autofocus
inputmode="tel"
placeholder="09121234567"
>
<template #prefix><VuesaxIcon name="mobile" :size="16" class="text-[#8e9ab0]" /></template>
</a-input>
</FormField>
<FormField path="password" label="رمز عبور">
<a-input-password
v-model:value="model.password"
size="large"
class="ltr-input"
autocomplete="current-password"
placeholder="••••••••"
>
<template #prefix><VuesaxIcon name="lock" :size="16" class="text-[#8e9ab0]" /></template>
</a-input-password>
</FormField>
<a-button
type="primary"
html-type="submit"
size="large"
block
:loading="loading"
class="!mt-2 !h-12 !rounded-full !font-bold !shadow-[0_8px_32px_rgba(255,90,0,0.35)]"
>
ورود به پنل
</a-button>
</a-form>
</div>
</div>
<!-- brand column -->
<div class="login-fade-1 lg:col-span-6">
<div
class="inline-flex items-center gap-2.5 rounded-full border border-[#ff5a00]/30 bg-[#ff5a00]/10 px-4 py-2 backdrop-blur"
>
<span class="size-1.5 animate-pulse rounded-full bg-[#ff5a00]" />
<span class="text-xs font-medium text-[#ff5a00]">پنل مدیریت ایمن پیشگامان</span>
</div>
<div class="mt-8 flex items-center gap-4">
<span
class="flex size-14 items-center justify-center rounded-xl bg-white shadow-[0_0_28px_rgba(10,30,92,0.45)]"
>
<img src="/logo.png" alt="ایمن پیشگامان" class="size-9 object-contain" />
</span>
<div class="leading-tight">
<div class="text-2xl font-black tracking-tight md:text-3xl">ایمن پیشگامان</div>
<div class="mt-1 font-mono text-[10px] tracking-[0.32em] text-[#8e9ab0]">
IMEN PISHGAMAN CO.
</div>
</div>
</div>
<h1 class="mt-8 text-3xl font-black leading-[1.25] md:text-5xl md:leading-[1.2]">
ورود امن
<span
class="mt-2 inline-block -rotate-1 rounded-lg bg-[#ffb800] px-3 py-1 text-[#0b1224] shadow-[0_10px_40px_rgba(255,184,0,0.22)]"
>
به سامانه
</span>
</h1>
<p class="mt-6 max-w-md text-sm leading-8 text-[#edede6]/70 md:text-base md:leading-9">
مدیریت محصولات، محتوا و پیام‌های سایت — فقط برای کاربران مجاز.
</p>
</div>
<a-form layout="vertical" @submit.prevent="submit">
<FormField path="email" label="ایمیل">
<a-input v-model:value="model.email" size="large" class="ltr-input" autocomplete="username" autofocus>
<template #prefix><MailOutlined class="text-gray-400" /></template>
</a-input>
</FormField>
<FormField path="password" label="رمز عبور">
<a-input-password v-model:value="model.password" size="large" class="ltr-input" autocomplete="current-password">
<template #prefix><LockOutlined class="text-gray-400" /></template>
</a-input-password>
</FormField>
<a-button type="primary" html-type="submit" size="large" block :loading="loading">ورود</a-button>
</a-form>
</div>
</div>
</template>
<style scoped>
.login-grid {
background-image:
linear-gradient(to left, rgba(237, 237, 230, 0.045) 1px, transparent 1px),
linear-gradient(to bottom, rgba(237, 237, 230, 0.045) 1px, transparent 1px);
background-size: 72px 72px;
}
.login-tape {
background-image: repeating-linear-gradient(45deg, #ffb800 0 10px, #0b1224 10px 20px);
}
.login-noise {
opacity: 0.045;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.login-fade-1,
.login-fade-3 {
animation: login-fade-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.login-fade-1 {
animation-delay: 0.12s;
}
.login-fade-3 {
animation-delay: 0.28s;
}
@keyframes login-fade-up {
from {
opacity: 0;
transform: translateY(36px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.login-panel :deep(.ant-form-item-label > label) {
color: #edede6 !important;
}
.login-panel :deep(.ant-input-affix-wrapper),
.login-panel :deep(.ant-input) {
background: #152038 !important;
border-color: #2a3d63 !important;
color: #edede6 !important;
}
.login-panel :deep(.ant-input-affix-wrapper:hover),
.login-panel :deep(.ant-input-affix-wrapper-focused),
.login-panel :deep(.ant-input-affix-wrapper:focus-within) {
border-color: #ff5a00 !important;
box-shadow: 0 0 0 2px rgba(255, 90, 0, 0.15) !important;
}
.login-panel :deep(.ant-input::placeholder) {
color: #8e9ab0 !important;
}
.login-panel :deep(.ant-input-password-icon) {
color: #8e9ab0 !important;
}
.login-panel :deep(.ant-form-item-explain-error) {
color: #ff7a2a;
}
</style>
+4 -4
View File
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { CopyOutlined, DeleteOutlined, UploadOutlined } from "@ant-design/icons-vue";
import type { MediaDto, Paginated } from "@imen/shared";
import { message } from "ant-design-vue";
import { onMounted, ref } from "vue";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import PageHeader from "@/components/PageHeader.vue";
import { faNumber, fileSize, jalali } from "@/utils/format";
@@ -89,7 +89,7 @@ onMounted(load);
<PageHeader title="کتابخانه رسانه" :subtitle="`${faNumber(total)} تصویر`">
<a-upload accept="image/jpeg,image/png,image/webp,image/avif,image/gif" multiple :show-upload-list="false" :before-upload="upload">
<a-button type="primary" :loading="uploading > 0">
<template #icon><UploadOutlined /></template>
<template #icon><VuesaxIcon name="document-upload" :size="16" /></template>
آپلود تصویر
</a-button>
</a-upload>
@@ -140,9 +140,9 @@ onMounted(load);
</a-form-item>
<a-space wrap>
<a-button type="primary" @click="saveAlt">ذخیره</a-button>
<a-button @click="copyUrl(selected.url)"><template #icon><CopyOutlined /></template>کپی آدرس</a-button>
<a-button @click="copyUrl(selected.url)"><template #icon><VuesaxIcon name="copy" :size="16" /></template>کپی آدرس</a-button>
<a-popconfirm title="این تصویر حذف شود؟" ok-text="حذف" cancel-text="انصراف" @confirm="remove">
<a-button danger><template #icon><DeleteOutlined /></template>حذف</a-button>
<a-button danger><template #icon><VuesaxIcon name="trash" :size="16" /></template>حذف</a-button>
</a-popconfirm>
</a-space>
</a-form>
+2 -2
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { DeleteOutlined } from "@ant-design/icons-vue";
import {
type ContactMessageDto,
MESSAGE_STATUS_LABELS,
@@ -11,6 +10,7 @@ import { message } from "ant-design-vue";
import { onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import PageHeader from "@/components/PageHeader.vue";
import { faNumber, jalali } from "@/utils/format";
@@ -117,7 +117,7 @@ onMounted(load);
</template>
<template v-else-if="column.key === 'actions'">
<a-popconfirm title="این پیام حذف شود؟" ok-text="حذف" cancel-text="انصراف" @confirm="remove(record as ContactMessageDto)">
<a-button size="small" danger><template #icon><DeleteOutlined /></template></a-button>
<a-button size="small" danger><template #icon><VuesaxIcon name="trash" :size="16" /></template></a-button>
</a-popconfirm>
</template>
</template>
+114 -13
View File
@@ -1,14 +1,16 @@
<script setup lang="ts">
import { CloseOutlined, PlusOutlined, SaveOutlined } from "@ant-design/icons-vue";
import { type MediaDto, productInputSchema } from "@imen/shared";
import { type MediaDto, type ProductAttribute, productInputSchema } from "@imen/shared";
import { message } from "ant-design-vue";
import { computed, onMounted, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import type { z } from "zod";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import type { AdminCategory, AdminCategoryDetail, AdminProductDetail } from "@/api/types";
import FormField from "@/components/FormField.vue";
import ImageField from "@/components/ImageField.vue";
import LinesInput from "@/components/LinesInput.vue";
import ListEditor from "@/components/ListEditor.vue";
import MediaPicker from "@/components/MediaPicker.vue";
import PageHeader from "@/components/PageHeader.vue";
import { useZodForm } from "@/composables/useZodForm";
@@ -31,6 +33,18 @@ const empty = (): Form => ({
desc: "",
specs: [],
variants: [],
details: "",
brand: "",
origin: "",
sizes: [],
standards: [],
features: [],
applications: [],
attributes: [],
packaging: "",
minOrder: "",
seoTitle: "",
seoDescription: "",
imageId: null,
galleryIds: [],
isPublished: true,
@@ -51,6 +65,7 @@ const groupId = computed({
get: () => model.value.groupId ?? undefined,
set: (v: number | undefined) => (model.value.groupId = v ?? null),
});
const newAttribute = (): ProductAttribute => ({ name: "", value: "" });
async function loadGroups(clear: boolean) {
if (clear) model.value.groupId = null;
@@ -75,6 +90,18 @@ async function load() {
desc: p.desc,
specs: p.specs,
variants: p.variants,
details: p.details,
brand: p.brand,
origin: p.origin,
sizes: p.sizes,
standards: p.standards,
features: p.features,
applications: p.applications,
attributes: p.attributes ?? [],
packaging: p.packaging,
minOrder: p.minOrder,
seoTitle: p.seoTitle,
seoDescription: p.seoDescription,
imageId: p.imageId,
galleryIds: p.gallery.map((g) => g.id),
isPublished: p.isPublished,
@@ -135,15 +162,15 @@ onMounted(load);
<template>
<PageHeader :title="id ? `ویرایش محصول: ${model.name}` : 'محصول جدید'" back="/products">
<a
v-if="id && category && model.isPublished"
:href="`${SITE_URL}/categories/${category.slug}`"
v-if="id && category?.isPublished && model.isPublished"
:href="`${SITE_URL}/products/${model.slug}`"
target="_blank"
rel="noopener"
>
<a-button>مشاهده در سایت</a-button>
</a>
<a-button type="primary" :loading="saving" @click="save">
<template #icon><SaveOutlined /></template>
<template #icon><VuesaxIcon name="save-2" :size="16" /></template>
ذخیره
</a-button>
</PageHeader>
@@ -163,26 +190,78 @@ onMounted(load);
<FormField path="code" label="کد محصول" required hint="یکتا، مثلاً IP-G20">
<a-input v-model:value="model.code" class="ltr-input" />
</FormField>
<FormField path="slug" label="اسلاگ" required>
<FormField path="slug" label="اسلاگ (آدرس صفحه)" required :hint="`آدرس: /products/${model.slug || '...'}`">
<a-input v-model:value="model.slug" class="ltr-input">
<template #suffix>
<a class="text-xs" @click="model.slug = toSlug(model.code || model.nameEn || '')">ساخت از کد</a>
</template>
</a-input>
</FormField>
<FormField path="desc" label="توضیحات" class="md:col-span-2">
<a-textarea v-model:value="model.desc" :auto-size="{ minRows: 3, maxRows: 8 }" />
<FormField path="desc" label="توضیح کوتاه" hint="زیر عنوان صفحه محصول و روی کارت محصول نمایش داده می‌شود" class="md:col-span-2">
<a-textarea v-model:value="model.desc" :auto-size="{ minRows: 2, maxRows: 5 }" />
</FormField>
<FormField path="specs" label="ویژگی‌ها" hint="هر ویژگی را بنویسید و Enter بزنید" class="md:col-span-2">
<FormField path="specs" label="برچسب‌های کوتاه" hint="ویژگی‌های یک‌کلمه‌ای روی کارت؛ هر مورد را بنویسید و Enter بزنید" class="md:col-span-2">
<a-select v-model:value="model.specs" mode="tags" :open="false" placeholder="مثلاً: ضد برش" />
</FormField>
<FormField path="variants" label="مدل‌ها / رنگ‌ها" hint="اختیاری — هر مورد را بنویسید و Enter بزنید" class="md:col-span-2">
</div>
</a-card>
<a-card title="توضیحات کامل (صفحه محصول)">
<FormField path="details" hint="برای شروع پاراگراف جدید یک خط خالی بگذارید. اگر خالی بماند، توضیح دسته نمایش داده می‌شود.">
<a-textarea
v-model:value="model.details"
:auto-size="{ minRows: 6, maxRows: 20 }"
placeholder="معرفی محصول، جنس و ساختار، مزایا، نکات نگهداری و ..."
/>
</FormField>
</a-card>
<a-card title="ویژگی‌ها و کاربردها">
<FormField path="features" label="ویژگی‌های کلیدی" hint="هر ویژگی در یک خط">
<LinesInput v-model="model.features" :rows="4" placeholder="مثلاً: زیره ضد لغزش و مقاوم در برابر روغن" />
</FormField>
<FormField path="applications" label="کاربردها / محیط‌های مناسب" hint="هر مورد را بنویسید و Enter بزنید">
<a-select v-model:value="model.applications" mode="tags" :open="false" placeholder="مثلاً: پالایشگاه" />
</FormField>
</a-card>
<a-card title="مشخصات فنی" :body-style="{ background: '#fafafa' }">
<p class="mb-4 text-sm text-gray-500">
ردیف‌های جدول مشخصات صفحه محصول (مثلاً «جنس رویه» ← «چرم طبیعی»). کد، دسته، برند و موارد زیر به‌صورت خودکار به جدول اضافه می‌شوند.
</p>
<ListEditor
v-model="model.attributes"
:create="newAttribute"
:max="40"
add-label="افزودن ردیف مشخصات"
:item-title="(a) => a.name"
>
<template #default="{ item, index }">
<div class="grid gap-x-4 md:grid-cols-5">
<FormField :path="`attributes.${index}.name`" label="عنوان" required class="md:col-span-2">
<a-input v-model:value="item.name" placeholder="مثلاً: جنس رویه" />
</FormField>
<FormField :path="`attributes.${index}.value`" label="مقدار" required class="md:col-span-3">
<a-input v-model:value="item.value" placeholder="مثلاً: چرم طبیعی گاوی" />
</FormField>
</div>
</template>
</ListEditor>
<div class="mt-6 grid gap-x-4 md:grid-cols-2">
<FormField path="standards" label="استانداردها و گواهی‌ها" hint="مثلاً EN 388 — هر مورد + Enter">
<a-select v-model:value="model.standards" mode="tags" :open="false" class="ltr-input" />
</FormField>
<FormField path="sizes" label="سایزها" hint="مثلاً 40، 41، XL — هر مورد + Enter">
<a-select v-model:value="model.sizes" mode="tags" :open="false" />
</FormField>
<FormField path="variants" label="مدل‌ها / رنگ‌ها" hint="هر مورد + Enter" class="md:col-span-2">
<a-select v-model:value="model.variants" mode="tags" :open="false" placeholder="مثلاً: مشکی/زرد" />
</FormField>
</div>
</a-card>
<a-card title="گالری تصاویر (اختیاری)">
<a-card title="گالری تصاویر">
<p class="mb-4 text-sm text-gray-500">تصاویر بیشتر محصول؛ در صفحه محصول بعد از تصویر اصلی نمایش داده می‌شوند.</p>
<div class="flex flex-wrap gap-3">
<div v-for="m in gallery" :key="m.id" class="relative size-24 overflow-hidden rounded-lg border border-gray-200 bg-gray-50">
<img :src="m.url" alt="" class="size-full object-contain" />
@@ -192,7 +271,7 @@ onMounted(load);
title="حذف از گالری"
@click="removeFromGallery(m.id)"
>
<CloseOutlined class="text-xs" />
<VuesaxIcon name="close-circle" :size="16" class="text-xs" />
</button>
</div>
<button
@@ -200,7 +279,7 @@ onMounted(load);
class="flex size-24 items-center justify-center rounded-lg border border-dashed border-gray-300 text-gray-400 hover:border-[#ff5a00] hover:text-[#ff5a00]"
@click="galleryPicker = true"
>
<PlusOutlined />
<VuesaxIcon name="add" :size="16" />
</button>
</div>
<MediaPicker v-model:open="galleryPicker" @select="addToGallery" />
@@ -238,6 +317,28 @@ onMounted(load);
<ImageField :url="image?.url" clearable @pick="pickImage" @clear="image = null; model.imageId = null" />
</FormField>
</a-card>
<a-card title="برند و سفارش">
<FormField path="brand" label="برند">
<a-input v-model:value="model.brand" />
</FormField>
<FormField path="origin" label="کشور سازنده">
<a-input v-model:value="model.origin" placeholder="مثلاً: ایران" />
</FormField>
<FormField path="packaging" label="بسته‌بندی">
<a-input v-model:value="model.packaging" placeholder="مثلاً: کارتن ۱۲ جفتی" />
</FormField>
<FormField path="minOrder" label="حداقل سفارش">
<a-input v-model:value="model.minOrder" placeholder="مثلاً: ۱ کارتن" />
</FormField>
</a-card>
<a-card title="سئو">
<FormField path="seoTitle" label="عنوان صفحه" hint="خالی = نام محصول">
<a-input v-model:value="model.seoTitle" :maxlength="120" show-count />
</FormField>
<FormField path="seoDescription" label="توضیحات متا" hint="خالی = توضیح کوتاه">
<a-textarea v-model:value="model.seoDescription" :maxlength="300" show-count :auto-size="{ minRows: 3 }" />
</FormField>
</a-card>
</div>
</div>
</a-form>
+316 -130
View File
@@ -1,31 +1,41 @@
<script setup lang="ts">
import {
ArrowDownOutlined,
ArrowUpOutlined,
CopyOutlined,
DeleteOutlined,
EditOutlined,
PlusOutlined,
} from "@ant-design/icons-vue";
import type { Paginated } from "@imen/shared";
import { message } from "ant-design-vue";
import { computed, onMounted, reactive, ref, watch } from "vue";
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { api, errorMessage } from "@/api/http";
import type { AdminCategory, AdminCategoryDetail, AdminProduct } from "@/api/types";
import PageHeader from "@/components/PageHeader.vue";
import { faNumber } from "@/utils/format";
import AdminPage from "@/components/AdminPage.vue";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
const route = useRoute();
const router = useRouter();
const tableShell = ref<HTMLElement | null>(null);
const scrollY = ref(360);
let tableResizeObserver: ResizeObserver | null = null;
function measureTableScroll() {
const el = tableShell.value;
if (!el) return;
const pagination = el.querySelector(".ant-table-pagination") as HTMLElement | null;
const header = el.querySelector(".ant-table-thead") as HTMLElement | null;
const paginationH = pagination?.offsetHeight ?? (reorderable.value ? 0 : 48);
const headerH = header?.offsetHeight ?? 55;
const gap = 16;
scrollY.value = Math.max(180, el.clientHeight - paginationH - headerH - gap);
}
const num = (v: unknown) => (v ? Number(v) : undefined);
const PAGE_SIZE_OPTIONS = ["10", "20", "50", "100"];
const DEFAULT_PAGE_SIZE = 20;
const filters = reactive({
categoryId: num(route.query.categoryId),
groupId: num(route.query.groupId),
status: (route.query.status as "published" | "draft" | undefined) || undefined,
q: typeof route.query.q === "string" ? route.query.q : "",
page: num(route.query.page) ?? 1,
pageSize: num(route.query.pageSize) ?? DEFAULT_PAGE_SIZE,
});
const rows = ref<AdminProduct[]>([]);
@@ -33,26 +43,67 @@ const total = ref(0);
const loading = ref(false);
const categories = ref<AdminCategory[]>([]);
const groups = ref<AdminCategoryDetail["groups"]>([]);
const filtersOpen = ref(false);
const activeFilterCount = computed(
() => [filters.categoryId, filters.groupId, filters.status].filter(Boolean).length,
);
/** products without their own photo show the category cover (same fallback as the website) */
const thumbOf = (row: AdminProduct) =>
row.image ? { url: row.image.url, fallback: false } : {
url: categories.value.find((c) => c.id === row.categoryId)?.coverImage?.url ?? null,
fallback: true,
};
row.image
? { url: row.image.url, fallback: false }
: {
url: categories.value.find((c) => c.id === row.categoryId)?.coverImage?.url ?? null,
fallback: true,
};
/** with a single category selected (and no other filter) the whole list is shown and can be reordered */
const reorderable = computed(() => !!filters.categoryId && !filters.groupId && !filters.status && !filters.q);
const pageSize = computed(() => (reorderable.value ? 200 : 30));
const reorderable = computed(
() => !!filters.categoryId && !filters.groupId && !filters.status && !filters.q,
);
const requestPageSize = computed(() => (reorderable.value ? 200 : filters.pageSize));
const tablePagination = computed(() => {
if (reorderable.value) return false;
return {
current: filters.page,
pageSize: filters.pageSize,
total: total.value,
showSizeChanger: true,
pageSizeOptions: PAGE_SIZE_OPTIONS,
showQuickJumper: true,
showTotal: (t: number) => `${t.toLocaleString("fa-IR")} محصول`,
onChange: (page: number, size: number) => {
filters.page = page;
if (size !== filters.pageSize) {
filters.pageSize = size;
filters.page = 1;
}
void load();
},
};
});
async function load() {
loading.value = true;
void router.replace({
query: Object.fromEntries(Object.entries(filters).filter(([k, v]) => v && !(k === "page" && v === 1))),
query: Object.fromEntries(
Object.entries({
...filters,
page: filters.page === 1 ? undefined : filters.page,
pageSize: filters.pageSize === DEFAULT_PAGE_SIZE ? undefined : filters.pageSize,
}).filter(([, v]) => v),
),
});
try {
const res = await api<Paginated<AdminProduct>>("/admin/products", {
query: { ...filters, q: filters.q || undefined, pageSize: pageSize.value },
query: {
...filters,
q: filters.q || undefined,
pageSize: requestPageSize.value,
},
});
rows.value = res.items;
total.value = res.total;
@@ -96,7 +147,9 @@ async function togglePublish(row: AdminProduct, isPublished: boolean) {
async function duplicate(row: AdminProduct) {
try {
const copy = await api<{ id: number }>(`/admin/products/${row.id}/duplicate`, { method: "POST" });
const copy = await api<{ id: number }>(`/admin/products/${row.id}/duplicate`, {
method: "POST",
});
void message.success("کپی پیش‌نویس ساخته شد");
await router.push({ name: "product-edit", params: { id: copy.id } });
} catch (e) {
@@ -136,6 +189,11 @@ const columns = computed(() => [
{ title: "", key: "actions", width: 130 },
]);
watch([reorderable, loading, rows], async () => {
await nextTick();
measureTableScroll();
});
onMounted(async () => {
try {
categories.value = await api<AdminCategory[]>("/admin/categories");
@@ -144,123 +202,251 @@ onMounted(async () => {
void message.error(errorMessage(e));
}
await load();
await nextTick();
if (tableShell.value) {
tableResizeObserver = new ResizeObserver(() => measureTableScroll());
tableResizeObserver.observe(tableShell.value);
measureTableScroll();
}
});
onBeforeUnmount(() => {
tableResizeObserver?.disconnect();
tableResizeObserver = null;
});
</script>
<template>
<PageHeader title="محصولات" :subtitle="`${faNumber(total)} محصول`">
<RouterLink :to="{ name: 'product-new', query: filters.categoryId ? { categoryId: filters.categoryId } : {} }">
<a-button type="primary">
<template #icon><PlusOutlined /></template>
محصول جدید
</a-button>
</RouterLink>
</PageHeader>
<AdminPage lock-body>
<template #head>
<div class="toolbar">
<div class="toolbar__start">
<a-popover
v-model:open="filtersOpen"
trigger="click"
placement="bottomLeft"
:overlay-style="{ width: '280px' }"
>
<template #content>
<div class="filter-panel">
<a-select
v-model:value="filters.categoryId"
allow-clear
style="width: 100%"
placeholder="همه دسته‌ها"
:options="categories.map((c) => ({ value: c.id, label: c.name }))"
/>
<a-select
v-model:value="filters.groupId"
allow-clear
style="width: 100%"
placeholder="همه زیرگروه‌ها"
:disabled="!groups.length"
:options="groups.map((g) => ({ value: g.id, label: g.name }))"
/>
<a-select
v-model:value="filters.status"
allow-clear
style="width: 100%"
placeholder="همه وضعیت‌ها"
:options="[
{ value: 'published', label: 'منتشرشده' },
{ value: 'draft', label: 'پیش‌نویس / مخفی' },
]"
/>
<p v-if="filters.categoryId && !reorderable" class="filter-panel__hint">
برای تغییر ترتیب، فقط فیلتر دسته را نگه دارید.
</p>
</div>
</template>
<a-badge :count="activeFilterCount" :offset="[-4, 4]" color="#ff5a00">
<a-button>
<template #icon><VuesaxIcon name="filter" :size="16" /></template>
فیلتر
</a-button>
</a-badge>
</a-popover>
<a-card class="mb-4" :body-style="{ padding: '16px' }">
<div class="grid gap-3 md:grid-cols-4">
<a-select
v-model:value="filters.categoryId"
allow-clear
placeholder="همه دسته‌ها"
:options="categories.map((c) => ({ value: c.id, label: c.name }))"
/>
<a-select
v-model:value="filters.groupId"
allow-clear
placeholder="همه زیرگروه‌ها"
:disabled="!groups.length"
:options="groups.map((g) => ({ value: g.id, label: g.name }))"
/>
<a-select
v-model:value="filters.status"
allow-clear
placeholder="همه وضعیت‌ها"
:options="[
{ value: 'published', label: 'منتشرشده' },
{ value: 'draft', label: 'پیش‌نویس / مخفی' },
]"
/>
<a-input-search
v-model:value="filters.q"
allow-clear
placeholder="جستجوی نام یا کد"
@search="() => { filters.page = 1; load(); }"
/>
</div>
<p v-if="filters.categoryId && !reorderable" class="mt-3 text-xs text-gray-400">
برای تغییر ترتیب محصولات، فقط فیلتر دسته را نگه دارید.
</p>
</a-card>
<a-input-search
v-model:value="filters.q"
allow-clear
class="toolbar__search"
placeholder="جستجوی نام یا کد"
@search="
() => {
filters.page = 1;
load();
}
"
/>
</div>
<a-card :body-style="{ padding: 0 }">
<a-table
:columns="columns"
:data-source="rows"
:loading="loading"
row-key="id"
:scroll="{ x: 760 }"
:pagination="reorderable ? false : {
current: filters.page,
pageSize,
total,
showSizeChanger: false,
onChange: (p: number) => { filters.page = p; load(); },
}"
>
<template #bodyCell="{ column, record, index }">
<template v-if="column.key === 'image'">
<template v-if="thumbOf(record as AdminProduct).url">
<img
:src="thumbOf(record as AdminProduct).url!"
alt=""
:title="thumbOf(record as AdminProduct).fallback ? 'این محصول عکس ندارد؛ کاور دسته نمایش داده شده' : undefined"
:class="['size-12 rounded bg-gray-50 object-contain', thumbOf(record as AdminProduct).fallback && 'opacity-40 grayscale']"
<RouterLink
class="toolbar__new"
:to="{
name: 'product-new',
query: filters.categoryId ? { categoryId: filters.categoryId } : {},
}"
>
<a-button type="primary">
<template #icon><VuesaxIcon name="add" :size="16" /></template>
محصول جدید
</a-button>
</RouterLink>
</div>
</template>
<div ref="tableShell" class="table-shell">
<a-table
class="table-shell__table"
:columns="columns"
:data-source="rows"
:loading="loading"
row-key="id"
:scroll="{ x: 760, y: scrollY }"
:pagination="tablePagination"
>
<template #bodyCell="{ column, record, index }">
<template v-if="column.key === 'image'">
<template v-if="thumbOf(record as AdminProduct).url">
<img
:src="thumbOf(record as AdminProduct).url!"
alt=""
:title="
thumbOf(record as AdminProduct).fallback
? 'این محصول عکس ندارد؛ کاور دسته نمایش داده شده'
: undefined
"
:class="[
'size-12 rounded bg-gray-50 object-contain',
thumbOf(record as AdminProduct).fallback && 'opacity-40 grayscale',
]"
/>
</template>
<div v-else class="size-12 rounded bg-gray-100" />
</template>
<template v-else-if="column.key === 'name'">
<RouterLink
:to="{ name: 'product-edit', params: { id: record.id } }"
class="font-bold text-[#0f172a] hover:text-[#ff5a00]"
>
{{ record.name }}
</RouterLink>
<div class="text-xs text-gray-400" dir="ltr">{{ record.code }}</div>
</template>
<template v-else-if="column.key === 'category'">
<div>{{ record.category.name }}</div>
<div v-if="record.group" class="text-xs text-gray-400">{{ record.group.name }}</div>
</template>
<template v-else-if="column.key === 'status'">
<a-switch
:checked="record.isPublished"
size="small"
@change="(v: unknown) => togglePublish(record as AdminProduct, !!v)"
/>
</template>
<div v-else class="size-12 rounded bg-gray-100" />
<template v-else-if="column.key === 'order'">
<a-space :size="4">
<a-button size="small" :disabled="index === 0" @click="move(index, -1)">
<template #icon><VuesaxIcon name="arrow-up" :size="14" /></template>
</a-button>
<a-button size="small" :disabled="index === rows.length - 1" @click="move(index, 1)">
<template #icon><VuesaxIcon name="arrow-down" :size="14" /></template>
</a-button>
</a-space>
</template>
<template v-else-if="column.key === 'actions'">
<a-space :size="4">
<RouterLink :to="{ name: 'product-edit', params: { id: record.id } }">
<a-button size="small" title="ویرایش"
><template #icon><VuesaxIcon name="edit-2" :size="14" /></template
></a-button>
</RouterLink>
<a-button size="small" title="کپی" @click="duplicate(record as AdminProduct)">
<template #icon><VuesaxIcon name="copy" :size="14" /></template>
</a-button>
<a-popconfirm
title="این محصول حذف شود؟"
ok-text="حذف"
cancel-text="انصراف"
@confirm="remove(record as AdminProduct)"
>
<a-button size="small" danger title="حذف"
><template #icon><VuesaxIcon name="trash" :size="14" /></template
></a-button>
</a-popconfirm>
</a-space>
</template>
</template>
<template v-else-if="column.key === 'name'">
<RouterLink :to="{ name: 'product-edit', params: { id: record.id } }" class="font-bold">
{{ record.name }}
</RouterLink>
<div class="text-xs text-gray-400" dir="ltr">{{ record.code }}</div>
</template>
<template v-else-if="column.key === 'category'">
<div>{{ record.category.name }}</div>
<div v-if="record.group" class="text-xs text-gray-400">{{ record.group.name }}</div>
</template>
<template v-else-if="column.key === 'status'">
<a-switch
:checked="record.isPublished"
size="small"
@change="(v: unknown) => togglePublish(record as AdminProduct, !!v)"
/>
</template>
<template v-else-if="column.key === 'order'">
<a-space :size="4">
<a-button size="small" :disabled="index === 0" @click="move(index, -1)">
<template #icon><ArrowUpOutlined /></template>
</a-button>
<a-button size="small" :disabled="index === rows.length - 1" @click="move(index, 1)">
<template #icon><ArrowDownOutlined /></template>
</a-button>
</a-space>
</template>
<template v-else-if="column.key === 'actions'">
<a-space :size="4">
<RouterLink :to="{ name: 'product-edit', params: { id: record.id } }">
<a-button size="small" title="ویرایش"><template #icon><EditOutlined /></template></a-button>
</RouterLink>
<a-button size="small" title="کپی" @click="duplicate(record as AdminProduct)">
<template #icon><CopyOutlined /></template>
</a-button>
<a-popconfirm title="این محصول حذف شود؟" ok-text="حذف" cancel-text="انصراف" @confirm="remove(record as AdminProduct)">
<a-button size="small" danger title="حذف"><template #icon><DeleteOutlined /></template></a-button>
</a-popconfirm>
</a-space>
</template>
</template>
</a-table>
</a-card>
</a-table>
</div>
</AdminPage>
</template>
<style scoped>
.table-shell {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
height: 100%;
}
.table-shell :deep(.ant-table-wrapper),
.table-shell :deep(.ant-spin-nested-loading),
.table-shell :deep(.ant-spin-container) {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
height: 100%;
}
.table-shell :deep(.ant-table) {
flex: 1;
min-height: 0;
}
.table-shell :deep(.ant-table-pagination) {
flex-shrink: 0;
margin: 12px 0 0 !important;
}
.toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
.toolbar__start {
display: flex;
flex: 1;
align-items: center;
gap: 16px;
min-width: 0;
}
.toolbar__search {
flex: 1;
min-width: 200px;
max-width: 360px;
}
.toolbar__new {
margin-inline-start: auto;
}
.filter-panel {
display: flex;
flex-direction: column;
gap: 10px;
}
.filter-panel__hint {
margin: 0;
font-size: 12px;
color: #94a3b8;
line-height: 1.6;
}
</style>
+1 -1
View File
@@ -37,7 +37,7 @@ async function save() {
<a-card title="مشخصات">
<a-descriptions :column="1">
<a-descriptions-item label="نام">{{ auth.user?.name }}</a-descriptions-item>
<a-descriptions-item label="ایمیل"><span dir="ltr">{{ auth.user?.email }}</span></a-descriptions-item>
<a-descriptions-item label="موبایل"><span dir="ltr">{{ auth.user?.phone }}</span></a-descriptions-item>
<a-descriptions-item label="نقش">{{ auth.user && ROLE_LABELS[auth.user.role] }}</a-descriptions-item>
</a-descriptions>
</a-card>
+2 -2
View File
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { SaveOutlined } from "@ant-design/icons-vue";
import { isSectionKey, SECTION_LABELS, type SectionKey, sectionSchemas } from "@imen/shared";
import { message } from "ant-design-vue";
import { type Component, computed, ref } from "vue";
import { useRoute } from "vue-router";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import type { SectionResponse } from "@/api/types";
import PageHeader from "@/components/PageHeader.vue";
import { useZodForm } from "@/composables/useZodForm";
@@ -92,7 +92,7 @@ if (valid) void load();
>
<a :href="SITE_URL" target="_blank" rel="noopener"><a-button>مشاهده سایت</a-button></a>
<a-button type="primary" :loading="saving" :disabled="!loaded" @click="save">
<template #icon><SaveOutlined /></template>
<template #icon><VuesaxIcon name="save-2" :size="16" /></template>
ذخیره
</a-button>
</PageHeader>
+16 -10
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons-vue";
import {
type AdminUserDto,
ROLE_LABELS,
@@ -12,6 +11,7 @@ import { message } from "ant-design-vue";
import { computed, onMounted, type Ref, ref } from "vue";
import type { z } from "zod";
import { api, errorMessage } from "@/api/http";
import VuesaxIcon from "@/components/VuesaxIcon.vue";
import FormField from "@/components/FormField.vue";
import PageHeader from "@/components/PageHeader.vue";
import { useZodForm } from "@/composables/useZodForm";
@@ -28,7 +28,7 @@ const saving = ref(false);
// one form model for both create and update; the matching schema validates on save
type Form = z.input<typeof userCreateSchema> & { isActive: boolean };
const empty: Form = { email: "", name: "", role: "EDITOR", password: "", isActive: true };
const empty: Form = { phone: "", name: "", role: "EDITOR", password: "", isActive: true };
const form = useZodForm(userCreateSchema, empty);
const model = form.model as unknown as Ref<Form>;
const isNew = computed(() => editing.value === 0);
@@ -50,7 +50,7 @@ function openNew() {
editing.value = 0;
}
function openEdit(u: AdminUserDto) {
form.reset({ email: u.email, name: u.name, role: u.role, isActive: u.isActive, password: "" } as Form);
form.reset({ phone: u.phone, name: u.name, role: u.role, isActive: u.isActive, password: "" } as Form);
editing.value = u.id;
}
@@ -92,7 +92,7 @@ async function remove(u: AdminUserDto) {
const columns = [
{ title: "نام", dataIndex: "name" },
{ title: "ایمیل", key: "email" },
{ title: "موبایل", key: "phone" },
{ title: "نقش", key: "role", width: 110 },
{ title: "وضعیت", key: "active", width: 100 },
{ title: "آخرین ورود", key: "login", width: 170 },
@@ -105,7 +105,7 @@ onMounted(load);
<template>
<PageHeader title="کاربران پنل" subtitle="مدیر کل به همه بخش‌ها دسترسی دارد؛ ویرایشگر به جز کاربران و تنظیمات سایت">
<a-button type="primary" @click="openNew">
<template #icon><PlusOutlined /></template>
<template #icon><VuesaxIcon name="add" :size="16" /></template>
کاربر جدید
</a-button>
</PageHeader>
@@ -113,7 +113,7 @@ onMounted(load);
<a-card :body-style="{ padding: 0 }">
<a-table :columns="columns" :data-source="rows" :loading="loading" row-key="id" :pagination="false" :scroll="{ x: 700 }">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'email'"><span dir="ltr">{{ record.email }}</span></template>
<template v-if="column.key === 'phone'"><span dir="ltr">{{ record.phone }}</span></template>
<template v-else-if="column.key === 'role'">
<a-tag :color="record.role === 'ADMIN' ? 'orange' : 'blue'">{{ ROLE_LABELS[record.role as keyof typeof ROLE_LABELS] }}</a-tag>
</template>
@@ -123,7 +123,7 @@ onMounted(load);
<template v-else-if="column.key === 'login'">{{ jalali(record.lastLoginAt) }}</template>
<template v-else-if="column.key === 'actions'">
<a-space :size="4">
<a-button size="small" @click="openEdit(record as AdminUserDto)"><template #icon><EditOutlined /></template></a-button>
<a-button size="small" @click="openEdit(record as AdminUserDto)"><template #icon><VuesaxIcon name="edit-2" :size="16" /></template></a-button>
<a-popconfirm
v-if="record.id !== auth.user?.id"
title="این کاربر حذف شود؟"
@@ -131,7 +131,7 @@ onMounted(load);
cancel-text="انصراف"
@confirm="remove(record as AdminUserDto)"
>
<a-button size="small" danger><template #icon><DeleteOutlined /></template></a-button>
<a-button size="small" danger><template #icon><VuesaxIcon name="trash" :size="16" /></template></a-button>
</a-popconfirm>
</a-space>
</template>
@@ -150,8 +150,14 @@ onMounted(load);
@cancel="editing = null"
>
<a-form layout="vertical" class="mt-4" @submit.prevent="save">
<FormField path="email" label="ایمیل" required>
<a-input v-model:value="model.email" class="ltr-input" :disabled="!isNew" />
<FormField path="phone" label="شماره موبایل" required>
<a-input
v-model:value="model.phone"
class="ltr-input"
:disabled="!isNew"
inputmode="tel"
placeholder="09121234567"
/>
</FormField>
<FormField path="name" label="نام" required>
<a-input v-model:value="model.name" />