提交
This commit is contained in:
1 parent
c87732fcd5
commit
058811ae77
107 files changed
+16983
-12758
No files matched your search
+171
-422
@@ -1,8 +1,87 @@
|
||||
import request from '@/utils/http'
|
||||
import type { AppRouteRecord } from '@/types/router'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 后端菜单 / 角色(与 router 后端模式、用户弹窗对齐)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** 后端菜单模式:拉取动态路由 */
|
||||
export async function fetchGetMenuList() {
|
||||
const res = await request.get<AppRouteRecord[] | { menuList?: AppRouteRecord[] }>({
|
||||
url: '/web/menu/list'
|
||||
})
|
||||
if (Array.isArray(res)) return res
|
||||
return res?.menuList || []
|
||||
}
|
||||
|
||||
/** 用户表单等:角色下拉 */
|
||||
export function fetchGetRoleList() {
|
||||
return request.get<Array<{ label: string; value: string }>>({
|
||||
url: '/web/admin/roles'
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 租户(系统管理)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function fetchTenantList(params?: { page?: number; pageSize?: number; keyword?: string }) {
|
||||
return request.get<{
|
||||
list: Api.Tenant.TenantItem[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
totalPages: number
|
||||
}>({
|
||||
url: '/web/admin/tenants',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchCreateTenant(data: {
|
||||
tenantNo: string
|
||||
tenantName: string
|
||||
contactName?: string
|
||||
contactPhone?: string
|
||||
orderNum?: number
|
||||
remark?: string
|
||||
}) {
|
||||
return request.post<Api.Tenant.TenantItem>({
|
||||
url: '/web/admin/tenants',
|
||||
data,
|
||||
showSuccessMessage: true
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchUpdateTenant(
|
||||
id: string,
|
||||
data: Partial<{
|
||||
tenantNo: string
|
||||
tenantName: string
|
||||
contactName: string
|
||||
contactPhone: string
|
||||
orderNum: number
|
||||
remark: string
|
||||
}>
|
||||
) {
|
||||
return request.put<Api.Tenant.TenantItem>({
|
||||
url: `/web/admin/tenants/${id}`,
|
||||
data,
|
||||
showSuccessMessage: true
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchDeleteTenant(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/tenants/${id}`,
|
||||
showSuccessMessage: true
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 用户
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
export function fetchUserList(params: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
@@ -24,18 +103,12 @@ export function fetchUserList(params: {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户详情
|
||||
*/
|
||||
export function fetchUserDetail(id: string) {
|
||||
return request.get<Api.User.UserDetail>({
|
||||
url: `/web/admin/users/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
export function fetchCreateUser(data: {
|
||||
username: string
|
||||
password: string
|
||||
@@ -52,27 +125,24 @@ export function fetchCreateUser(data: {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*/
|
||||
export function fetchUpdateUser(id: string, data: Partial<{
|
||||
realName: string
|
||||
phone?: string
|
||||
role: string
|
||||
regionId?: string
|
||||
regionIds?: string[]
|
||||
isActive: boolean
|
||||
avatarUrl?: string | null
|
||||
}>) {
|
||||
export function fetchUpdateUser(
|
||||
id: string,
|
||||
data: Partial<{
|
||||
realName: string
|
||||
phone?: string
|
||||
role: string
|
||||
regionId?: string
|
||||
regionIds?: string[]
|
||||
isActive: boolean
|
||||
avatarUrl?: string | null
|
||||
}>
|
||||
) {
|
||||
return request.put({
|
||||
url: `/web/admin/users/${id}`,
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 可授权菜单 code 列表
|
||||
*/
|
||||
export function fetchAssignableMenuCodes() {
|
||||
return request.get<{
|
||||
list: Array<{
|
||||
@@ -87,9 +157,6 @@ export function fetchAssignableMenuCodes() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户菜单授权
|
||||
*/
|
||||
export function fetchUserMenuScopes(userId: string) {
|
||||
return request.get<{
|
||||
userId: string
|
||||
@@ -99,9 +166,6 @@ export function fetchUserMenuScopes(userId: string) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户菜单授权(全量覆盖)
|
||||
*/
|
||||
export function fetchUpdateUserMenuScopes(userId: string, menuCodes: string[]) {
|
||||
return request.post({
|
||||
url: `/web/admin/users/${userId}/menu-scopes`,
|
||||
@@ -109,41 +173,31 @@ export function fetchUpdateUserMenuScopes(userId: string, menuCodes: string[]) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
export function fetchDeleteUser(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/users/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*/
|
||||
export function fetchResetPassword(id: string) {
|
||||
return request.post({
|
||||
url: `/web/admin/users/${id}/reset-password`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
*/
|
||||
export function fetchChangePassword(data: {
|
||||
oldPassword: string
|
||||
newPassword: string
|
||||
}) {
|
||||
return request.post({
|
||||
url: '/web/admin/users/change-password',
|
||||
params: data
|
||||
/** 上传用户头像,返回存储后的 URL,供写入 avatarUrl */
|
||||
export function fetchUploadUserAvatar(data: FormData) {
|
||||
return request.post<{ url: string }>({
|
||||
url: '/web/admin/users/upload-avatar',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域列表
|
||||
*/
|
||||
export function fetchRegionList(params?: {
|
||||
// ---------------------------------------------------------------------------
|
||||
// 区域(仅列表分页供 fetchNotDeletedRegions 使用 + 启用列表)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function fetchRegionList(params?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
keyword?: string
|
||||
@@ -161,36 +215,29 @@ export function fetchRegionList(params?: {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取启用的区域列表
|
||||
*/
|
||||
export function fetchActiveRegions() {
|
||||
// 简单缓存:区域列表变化频率低,避免页面间重复请求导致“区域加载慢”
|
||||
// 5 分钟 TTL;需要实时刷新时可在调用方自行绕过(后续可升级为 Pinia store)
|
||||
const now = Date.now()
|
||||
const anyFn = fetchActiveRegions as any
|
||||
const cache = anyFn.__cache as undefined | { ts: number; data: Api.Region.RegionItem[] }
|
||||
if (cache && now - cache.ts < 5 * 60 * 1000) return Promise.resolve(cache.data)
|
||||
|
||||
return request.get<Api.Region.RegionItem[]>({
|
||||
url: '/web/admin/regions/active'
|
||||
}).then((data) => {
|
||||
anyFn.__cache = { ts: now, data: data || [] }
|
||||
return data
|
||||
})
|
||||
return request
|
||||
.get<Api.Region.RegionItem[]>({
|
||||
url: '/web/admin/regions/active'
|
||||
})
|
||||
.then((data) => {
|
||||
anyFn.__cache = { ts: now, data: data || [] }
|
||||
return data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有未删除的区域(包含禁用态 isActive=0)
|
||||
* 用于后台各模块“区域 tab”展示全量范围。
|
||||
*/
|
||||
/** 未删除的全量区域(含禁用),供各页区域 Tab */
|
||||
export async function fetchNotDeletedRegions() {
|
||||
const now = Date.now()
|
||||
const anyFn = fetchNotDeletedRegions as any
|
||||
const cache = anyFn.__cache as undefined | { ts: number; data: Api.Region.RegionItem[] }
|
||||
if (cache && now - cache.ts < 5 * 60 * 1000) return cache.data
|
||||
|
||||
// 注意:后端 `GET /web/admin/regions` 的 pageSize 有上限(<=100),不能一次性拉太大。
|
||||
const pageSize = 100
|
||||
const all: Api.Region.RegionItem[] = []
|
||||
let page = 1
|
||||
@@ -201,7 +248,6 @@ export async function fetchNotDeletedRegions() {
|
||||
all.push(...list)
|
||||
|
||||
const total = Number(res?.total ?? 0)
|
||||
// 没有更多数据:直接退出(避免死循环)
|
||||
if (!total || all.length >= total || list.length < pageSize) break
|
||||
page++
|
||||
}
|
||||
@@ -210,64 +256,10 @@ export async function fetchNotDeletedRegions() {
|
||||
return all
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取区域详情
|
||||
*/
|
||||
export function fetchRegionDetail(id: string) {
|
||||
return request.get<Api.Region.RegionDetail>({
|
||||
url: `/web/admin/regions/${id}`
|
||||
})
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// 商品分类
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 创建区域
|
||||
*/
|
||||
export function fetchCreateRegion(data: {
|
||||
name: string
|
||||
code: string
|
||||
description?: string
|
||||
sortOrder?: number
|
||||
/** 预计配送时长(分钟) */
|
||||
expectedDeliveryMinutes?: number | null
|
||||
/** 计划到货前未送达时预警提前时间(分钟) */
|
||||
deliveryWarnAdvanceMinutes?: number | null
|
||||
}) {
|
||||
return request.post({
|
||||
url: '/web/admin/regions',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新区域
|
||||
*/
|
||||
export function fetchUpdateRegion(id: string, data: Partial<{
|
||||
name: string
|
||||
code: string
|
||||
description?: string
|
||||
sortOrder?: number
|
||||
isActive?: boolean
|
||||
expectedDeliveryMinutes?: number | null
|
||||
deliveryWarnAdvanceMinutes?: number | null
|
||||
}>) {
|
||||
return request.put({
|
||||
url: `/web/admin/regions/${id}`,
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除区域
|
||||
*/
|
||||
export function fetchDeleteRegion(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/regions/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类列表
|
||||
*/
|
||||
export function fetchCategoryList(params?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
@@ -286,24 +278,11 @@ export function fetchCategoryList(params?: {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品分类树
|
||||
*/
|
||||
export function fetchCategoryTree() {
|
||||
return request.get<any[]>({
|
||||
url: '/web/admin/categories/tree'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品分类
|
||||
*/
|
||||
export function fetchCreateCategory(data: {
|
||||
name: string
|
||||
parentId?: string
|
||||
sortOrder?: number
|
||||
imageUrl?: string
|
||||
/** 价格系数,百分比点数(如 5 表示 5%) */
|
||||
priceCoefficient?: number
|
||||
}) {
|
||||
return request.post({
|
||||
@@ -312,35 +291,29 @@ export function fetchCreateCategory(data: {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品分类
|
||||
*/
|
||||
export function fetchUpdateCategory(id: string, data: Partial<{
|
||||
name: string
|
||||
parentId?: string
|
||||
sortOrder?: number
|
||||
isActive?: boolean
|
||||
imageUrl?: string
|
||||
priceCoefficient?: number
|
||||
}>) {
|
||||
export function fetchUpdateCategory(
|
||||
id: string,
|
||||
data: Partial<{
|
||||
name: string
|
||||
parentId?: string
|
||||
sortOrder?: number
|
||||
isActive?: boolean
|
||||
imageUrl?: string
|
||||
priceCoefficient?: number
|
||||
}>
|
||||
) {
|
||||
return request.put({
|
||||
url: `/web/admin/categories/${id}`,
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品分类
|
||||
*/
|
||||
export function fetchDeleteCategory(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/categories/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传商品分类图片(MinIO)并返回图片URL
|
||||
*/
|
||||
export function fetchUploadCategoryImage(data: FormData) {
|
||||
return request.post({
|
||||
url: '/web/admin/categories/upload-image',
|
||||
@@ -348,17 +321,10 @@ export function fetchUploadCategoryImage(data: FormData) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 上传用户头像,返回 MinIO 等存储后的 URL,供写入 avatarUrl */
|
||||
export function fetchUploadUserAvatar(data: FormData) {
|
||||
return request.post<{ url: string }>({
|
||||
url: '/web/admin/users/upload-avatar',
|
||||
data
|
||||
})
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// 商品单位
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 获取商品单位列表
|
||||
*/
|
||||
export function fetchUnitList(params?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
@@ -377,45 +343,37 @@ export function fetchUnitList(params?: {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品单位
|
||||
*/
|
||||
export function fetchCreateUnit(data: {
|
||||
name: string
|
||||
code: string
|
||||
}) {
|
||||
export function fetchCreateUnit(data: { name: string; code: string }) {
|
||||
return request.post({
|
||||
url: '/web/admin/units',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品单位
|
||||
*/
|
||||
export function fetchUpdateUnit(id: string, data: Partial<{
|
||||
name: string
|
||||
code: string
|
||||
isActive?: boolean
|
||||
}>) {
|
||||
export function fetchUpdateUnit(
|
||||
id: string,
|
||||
data: Partial<{
|
||||
name: string
|
||||
code: string
|
||||
isActive?: boolean
|
||||
}>
|
||||
) {
|
||||
return request.put({
|
||||
url: `/web/admin/units/${id}`,
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品单位
|
||||
*/
|
||||
export function fetchDeleteUnit(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/units/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
// 商品
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function fetchProductList(params?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
@@ -435,18 +393,12 @@ export function fetchProductList(params?: {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品详情
|
||||
*/
|
||||
export function fetchProductDetail(id: string) {
|
||||
return request.get<Api.Product.ProductDetail>({
|
||||
url: `/web/admin/products/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品在各启用区域的当前生效价(来自该区域生效中的价格清单)
|
||||
*/
|
||||
export function fetchProductRegionPrices(productId: string) {
|
||||
return request.get<{
|
||||
list: Array<{
|
||||
@@ -461,9 +413,6 @@ export function fetchProductRegionPrices(productId: string) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品
|
||||
*/
|
||||
export function fetchCreateProduct(data: {
|
||||
name: string
|
||||
skuCode?: string
|
||||
@@ -472,7 +421,6 @@ export function fetchCreateProduct(data: {
|
||||
measureValue?: number | null
|
||||
description?: string
|
||||
imageUrl?: string
|
||||
/** 调价系数(%):百分比点数,5 表示 5% */
|
||||
priceCoefficient?: number
|
||||
isActive?: boolean
|
||||
detailContent?: string
|
||||
@@ -483,41 +431,35 @@ export function fetchCreateProduct(data: {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
*/
|
||||
export function fetchUpdateProduct(id: string, data: Partial<{
|
||||
name: string
|
||||
skuCode?: string
|
||||
categoryId?: string
|
||||
unitId?: string
|
||||
measureValue?: number | null
|
||||
description?: string
|
||||
imageUrl?: string
|
||||
priceCoefficient?: number
|
||||
isActive?: boolean
|
||||
detailContent?: string
|
||||
}>) {
|
||||
export function fetchUpdateProduct(
|
||||
id: string,
|
||||
data: Partial<{
|
||||
name: string
|
||||
skuCode?: string
|
||||
categoryId?: string
|
||||
unitId?: string
|
||||
measureValue?: number | null
|
||||
description?: string
|
||||
imageUrl?: string
|
||||
priceCoefficient?: number
|
||||
isActive?: boolean
|
||||
detailContent?: string
|
||||
}>
|
||||
) {
|
||||
return request.put({
|
||||
url: `/web/admin/products/${id}`,
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*/
|
||||
export function fetchDeleteProduct(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/products/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
// ========== 商品轮播图 ==========
|
||||
// --- 轮播图 ---
|
||||
|
||||
/**
|
||||
* 获取商品轮播图列表
|
||||
*/
|
||||
export function fetchProductBannerList(productId: string) {
|
||||
return request.get<{
|
||||
list: Api.Product.ProductBanner[]
|
||||
@@ -527,9 +469,6 @@ export function fetchProductBannerList(productId: string) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加商品轮播图
|
||||
*/
|
||||
export function fetchCreateProductBanners(productId: string, items: Api.Product.ProductBannerCreate[]) {
|
||||
return request.post({
|
||||
url: `/web/admin/product-banners/product/${productId}`,
|
||||
@@ -537,19 +476,6 @@ export function fetchCreateProductBanners(productId: string, items: Api.Product.
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新轮播图
|
||||
*/
|
||||
export function fetchUpdateProductBanner(id: string, data: Partial<Api.Product.ProductBannerUpdate>) {
|
||||
return request.put({
|
||||
url: `/web/admin/product-banners/${id}`,
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新轮播图排序
|
||||
*/
|
||||
export function fetchUpdateProductBannerSort(productId: string, items: { id: string; sortOrder: number }[]) {
|
||||
return request.put({
|
||||
url: `/web/admin/product-banners/product/${productId}/sort`,
|
||||
@@ -557,20 +483,14 @@ export function fetchUpdateProductBannerSort(productId: string, items: { id: str
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除轮播图
|
||||
*/
|
||||
export function fetchDeleteProductBanner(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/product-banners/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
// ========== 商品详情媒体 ==========
|
||||
// --- 详情媒体 ---
|
||||
|
||||
/**
|
||||
* 获取商品详情媒体列表
|
||||
*/
|
||||
export function fetchProductDetailMediaList(productId: string) {
|
||||
return request.get<{
|
||||
list: Api.Product.ProductDetailMedia[]
|
||||
@@ -580,29 +500,16 @@ export function fetchProductDetailMediaList(productId: string) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加商品详情媒体
|
||||
*/
|
||||
export function fetchCreateProductDetailMedia(productId: string, items: Api.Product.ProductDetailMediaCreate[]) {
|
||||
export function fetchCreateProductDetailMedia(
|
||||
productId: string,
|
||||
items: Api.Product.ProductDetailMediaCreate[]
|
||||
) {
|
||||
return request.post({
|
||||
url: `/web/admin/product-detail-media/product/${productId}`,
|
||||
params: items
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新详情媒体
|
||||
*/
|
||||
export function fetchUpdateProductDetailMedia(id: string, data: Partial<Api.Product.ProductDetailMediaUpdate>) {
|
||||
return request.put({
|
||||
url: `/web/admin/product-detail-media/${id}`,
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新详情媒体排序
|
||||
*/
|
||||
export function fetchUpdateProductDetailMediaSort(productId: string, items: { id: string; sortOrder: number }[]) {
|
||||
return request.put({
|
||||
url: `/web/admin/product-detail-media/product/${productId}/sort`,
|
||||
@@ -610,40 +517,14 @@ export function fetchUpdateProductDetailMediaSort(productId: string, items: { id
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除详情媒体
|
||||
*/
|
||||
export function fetchDeleteProductDetailMedia(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/product-detail-media/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
// ========== 商品参数模板 ==========
|
||||
// --- 参数模板(简洁列表供分类/商品选择) ---
|
||||
|
||||
/**
|
||||
* 获取参数模板列表
|
||||
*/
|
||||
export function fetchProductParameterList(params?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
keyword?: string
|
||||
isActive?: number
|
||||
}) {
|
||||
return request.get<{
|
||||
list: Api.Product.ProductParameter[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}>({
|
||||
url: '/web/admin/product-parameters',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数模板简洁列表
|
||||
*/
|
||||
export function fetchProductParameterSimple() {
|
||||
return request.get<{
|
||||
list: Api.Product.ProductParameterSimple[]
|
||||
@@ -653,49 +534,8 @@ export function fetchProductParameterSimple() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数模板详情
|
||||
*/
|
||||
export function fetchProductParameterDetail(id: string) {
|
||||
return request.get<Api.Product.ProductParameter>({
|
||||
url: `/web/admin/product-parameters/${id}`
|
||||
})
|
||||
}
|
||||
// --- 分类关联参数 ---
|
||||
|
||||
/**
|
||||
* 创建参数模板
|
||||
*/
|
||||
export function fetchCreateProductParameter(data: Api.Product.ProductParameterCreate) {
|
||||
return request.post({
|
||||
url: '/web/admin/product-parameters',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新参数模板
|
||||
*/
|
||||
export function fetchUpdateProductParameter(id: string, data: Partial<Api.Product.ProductParameterUpdate>) {
|
||||
return request.put({
|
||||
url: `/web/admin/product-parameters/${id}`,
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除参数模板
|
||||
*/
|
||||
export function fetchDeleteProductParameter(id: string) {
|
||||
return request.del({
|
||||
url: `/web/admin/product-parameters/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
// ========== 分类参数关联 ==========
|
||||
|
||||
/**
|
||||
* 获取分类关联的参数列表
|
||||
*/
|
||||
export function fetchCategoryParameters(categoryId: string) {
|
||||
return request.get<{
|
||||
list: Api.Product.CategoryParameter[]
|
||||
@@ -705,9 +545,6 @@ export function fetchCategoryParameters(categoryId: string) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新分类关联的参数
|
||||
*/
|
||||
export function fetchUpdateCategoryParameters(categoryId: string, items: Api.Product.CategoryParameterCreate[]) {
|
||||
return request.put({
|
||||
url: `/web/admin/categories/${categoryId}/parameters`,
|
||||
@@ -715,11 +552,8 @@ export function fetchUpdateCategoryParameters(categoryId: string, items: Api.Pro
|
||||
})
|
||||
}
|
||||
|
||||
// ========== 商品参数值 ==========
|
||||
// --- 商品参数值 ---
|
||||
|
||||
/**
|
||||
* 获取商品参数值列表
|
||||
*/
|
||||
export function fetchProductParameterValues(productId: string) {
|
||||
return request.get<{
|
||||
list: Api.Product.ProductParameterValue[]
|
||||
@@ -729,97 +563,12 @@ export function fetchProductParameterValues(productId: string) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存商品参数值
|
||||
*/
|
||||
export function fetchSaveProductParameterValues(productId: string, values: Api.Product.ProductParameterValueCreate[]) {
|
||||
export function fetchSaveProductParameterValues(
|
||||
productId: string,
|
||||
values: Api.Product.ProductParameterValueCreate[]
|
||||
) {
|
||||
return request.post({
|
||||
url: `/web/admin/product-parameter-values/product/${productId}`,
|
||||
params: { productId, values }
|
||||
})
|
||||
}
|
||||
|
||||
// ========== 售后评价 ==========
|
||||
|
||||
/**
|
||||
* 获取评价列表
|
||||
*/
|
||||
export function fetchReviewList(params?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
productId?: string
|
||||
productName?: string
|
||||
userName?: string
|
||||
status?: string
|
||||
rating?: number
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
}) {
|
||||
return request.get<{
|
||||
list: Api.Product.ProductReview[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}>({
|
||||
url: '/web/admin/reviews',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评价统计
|
||||
*/
|
||||
export function fetchReviewStatistics(productId?: string) {
|
||||
return request.get<Api.Product.ProductReviewStatistics>({
|
||||
url: '/web/admin/reviews/statistics',
|
||||
params: { productId }
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评价详情
|
||||
*/
|
||||
export function fetchReviewDetail(id: string) {
|
||||
return request.get<Api.Product.ProductReview>({
|
||||
url: `/web/admin/reviews/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核通过评价
|
||||
*/
|
||||
export function fetchApproveReview(id: string) {
|
||||
return request.put({
|
||||
url: `/web/admin/reviews/${id}/approve`
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝评价
|
||||
*/
|
||||
export function fetchRejectReview(id: string, rejectReason: string) {
|
||||
return request.put({
|
||||
url: `/web/admin/reviews/${id}/reject`,
|
||||
params: { rejectReason }
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复评价
|
||||
*/
|
||||
export function fetchReplyReview(id: string, replyContent: string) {
|
||||
return request.put({
|
||||
url: `/web/admin/reviews/${id}/reply`,
|
||||
params: { replyContent }
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 置顶/取消置顶评价
|
||||
*/
|
||||
export function fetchToggleReviewTop(id: string, isTop: number) {
|
||||
return request.put({
|
||||
url: `/web/admin/reviews/${id}/top`,
|
||||
params: { isTop }
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 订单与订单页依赖的少量接口(其余业务 API 已移除,需要时再加回)。
|
||||
*/
|
||||
|
||||
export function fetchOrderList(params: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
keyword?: string
|
||||
status?: string
|
||||
orderStatus?: string
|
||||
deliveryStatus?: string
|
||||
payStatus?: string
|
||||
paymentMethod?: string
|
||||
regionId?: string
|
||||
clientId?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
}) {
|
||||
return request.get<{
|
||||
list: Api.Order.OrderItem[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
totalPages: number
|
||||
}>({
|
||||
url: '/web/admin/orders',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchOrderDetail(id: string) {
|
||||
return request.get<Api.Order.OrderDetail>({
|
||||
url: `/web/admin/orders/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchAssignDelivery(data: {
|
||||
orderId: string
|
||||
deliverId: string
|
||||
deliveryDeadlineAt: string
|
||||
dispatchRemark?: string
|
||||
}) {
|
||||
return request.post({
|
||||
url: `/web/admin/orders/${data.orderId}/assign-deliverer`,
|
||||
params: {
|
||||
deliverId: data.deliverId,
|
||||
deliveryDeadlineAt: data.deliveryDeadlineAt,
|
||||
dispatchRemark: data.dispatchRemark || ''
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchReviewCancel(data: { orderId: string; approved: boolean; note?: string }) {
|
||||
return request.post({
|
||||
url: `/web/admin/orders/${data.orderId}/review-cancel`,
|
||||
params: { approved: data.approved, note: data.note }
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchCancelOrder(data: {
|
||||
orderId: string
|
||||
reason: string
|
||||
note?: string
|
||||
evidenceImageUrls?: string[]
|
||||
}) {
|
||||
return request.post({
|
||||
url: `/web/admin/orders/${data.orderId}/cancel`,
|
||||
params: {
|
||||
reason: data.reason,
|
||||
note: data.note,
|
||||
evidenceImageUrls: data.evidenceImageUrls || []
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchOrderAdjusts(orderId: string) {
|
||||
return request.get({
|
||||
url: `/web/admin/orders/${orderId}/adjusts`
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchAdjustOrder(data: {
|
||||
orderId: string
|
||||
adjustments?: Array<{
|
||||
orderItemId: string
|
||||
adjustType: 'reduce' | 'delete' | 'substitute' | 'increase'
|
||||
newQuantity?: number
|
||||
newProductId?: string
|
||||
reason: string
|
||||
}>
|
||||
addressUpdate?: {
|
||||
deliveryAddress?: string
|
||||
contactPerson?: string
|
||||
contactPhone?: string
|
||||
reason?: string
|
||||
}
|
||||
}) {
|
||||
return request.post({
|
||||
url: `/web/admin/orders/${data.orderId}/adjust`,
|
||||
params: {
|
||||
adjustments: data.adjustments || [],
|
||||
addressUpdate: data.addressUpdate || undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchOrderItems(orderId: string) {
|
||||
return request.get({
|
||||
url: `/web/admin/orders/${orderId}/items`
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchPriceVersionDetail(id: string) {
|
||||
return request.get({
|
||||
url: `/web/admin/price-versions/${id}`
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchUploadAttachment(data: FormData) {
|
||||
return request.post<{
|
||||
id: string
|
||||
fileName: string
|
||||
fileUrl: string
|
||||
fileSize: number
|
||||
fileSizeDisplay?: string
|
||||
fileType?: string
|
||||
}>({
|
||||
url: '/web/admin/attachment/upload',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchUploadProductImage(data: FormData) {
|
||||
return request.post({
|
||||
url: '/web/admin/products/upload-image',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchSystemConfig() {
|
||||
return request.get({
|
||||
url: '/web/admin/system-config/settings'
|
||||
})
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import request from '@/utils/http'
|
||||
import type { AppRouteRecord } from '@/types/router'
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* 从后端获取运营端菜单
|
||||
*/
|
||||
export async function fetchGetMenuList() {
|
||||
const res = await request.get<AppRouteRecord[] | { menuList?: AppRouteRecord[] }>({
|
||||
url: '/web/menu/list'
|
||||
})
|
||||
if (Array.isArray(res)) return res
|
||||
return res?.menuList || []
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色列表
|
||||
*/
|
||||
export function fetchGetRoleList() {
|
||||
return request.get<Array<{ label: string; value: string }>>({
|
||||
url: '/web/admin/roles'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 示例表格用户列表(兼容旧示例页调用)
|
||||
*/
|
||||
export function fetchGetUserList(params?: Record<string, any>) {
|
||||
return request.get<{
|
||||
list: any[]
|
||||
total: number
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}>({
|
||||
url: '/web/admin/users',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<teleport to="body">
|
||||
<div v-show="visibleProxy" class="order-operate-bridge-layer" @click.self="visibleProxy = false">
|
||||
<div class="order-operate-bridge-dialog">
|
||||
<iframe ref="frameRef" class="order-operate-bridge-frame" :src="frameSrc" frameborder="0" />
|
||||
</div>
|
||||
</div>
|
||||
</teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
orderId: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
}>()
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: boolean) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const frameSrc = computed(() => {
|
||||
return `#/demo/order?embedded=1`
|
||||
})
|
||||
|
||||
const frameRef = ref<HTMLIFrameElement | null>(null)
|
||||
|
||||
const handleMessage = (ev: MessageEvent) => {
|
||||
const data = ev?.data as any
|
||||
if (!data || typeof data !== 'object') return
|
||||
if (data.type === 'sqxp-order-operate-close') {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const postOpen = (id: string) => {
|
||||
const win = frameRef.value?.contentWindow
|
||||
if (!win) return
|
||||
win.postMessage({ type: 'sqxp-order-operate-open', orderId: id }, '*')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('message', handleMessage)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('message', handleMessage)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [visibleProxy.value, props.orderId] as const,
|
||||
([vis, id]) => {
|
||||
if (!vis) return
|
||||
const orderId = (id || '').trim()
|
||||
if (!orderId) return
|
||||
// 给 iframe 一帧时间完成渲染/初始化后再发消息,避免首次打开时丢消息
|
||||
requestAnimationFrame(() => postOpen(orderId))
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.order-operate-bridge-layer {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 4000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(0, 0, 0, 0.28);
|
||||
padding: 48px 24px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.order-operate-bridge-dialog {
|
||||
width: min(1400px, calc(100vw - 48px));
|
||||
max-height: calc(100vh - 96px);
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow:
|
||||
0 20px 64px rgba(15, 23, 42, 0.25),
|
||||
0 2px 12px rgba(15, 23, 42, 0.12);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.order-operate-bridge-frame {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 680px;
|
||||
max-height: calc(100vh - 96px);
|
||||
display: block;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.order-operate-bridge-empty {
|
||||
flex: 1 1 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.order-operate-bridge-layer {
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
.order-operate-bridge-dialog {
|
||||
width: calc(100vw - 20px);
|
||||
max-height: calc(100vh - 40px);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.order-operate-bridge-frame {
|
||||
min-height: 520px;
|
||||
max-height: calc(100vh - 40px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<teleport to="body">
|
||||
<div v-show="visibleProxy" class="order-operate-local-layer" @click.self="visibleProxy = false">
|
||||
<iframe class="order-operate-local-frame" :src="frameSrc" frameborder="0" allowtransparency="true" />
|
||||
</div>
|
||||
</teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
orderId: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
}>()
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: boolean) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const frameSrc = computed(() => {
|
||||
const id = encodeURIComponent((props.orderId || '').trim())
|
||||
return id ? `#/demo/order?bridge=1&viewOrderId=${id}` : '#/demo/order?bridge=1'
|
||||
})
|
||||
|
||||
const handleMessage = (ev: MessageEvent) => {
|
||||
const data = ev?.data as any
|
||||
if (!data || typeof data !== 'object') return
|
||||
if (data.type === 'sqxp-order-operate-close') {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('message', handleMessage)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('message', handleMessage)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.order-operate-local-layer {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 4000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: transparent;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.order-operate-local-frame {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
display: block;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -4,7 +4,7 @@
|
||||
<img
|
||||
:style="logoStyle"
|
||||
src="/logo1.jpg"
|
||||
alt="中科兴皖一体化门户"
|
||||
alt="陇耘鲜达"
|
||||
class="block object-contain"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,330 +0,0 @@
|
||||
<!-- 地图图表 -->
|
||||
<template>
|
||||
<div class="relative w-full" :style="{ height: 'calc(100vh - 120px)' }">
|
||||
<div v-if="isEmpty" class="h-full flex-cc">
|
||||
<ElEmpty description="暂无地图数据" />
|
||||
</div>
|
||||
|
||||
<div v-else id="china-map" ref="chinaMapRef" class="h-full w-full overflow-hidden rounded-lg" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, shallowRef, computed, watch, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
import { echarts } from '@/plugins/echarts'
|
||||
import { useSettingStore } from '@/store/modules/setting'
|
||||
import { fetchGetChinaMapData } from '@/api/system'
|
||||
import type { MapChartProps } from '@/types/component/chart'
|
||||
|
||||
defineOptions({ name: 'ArtMapChart' })
|
||||
|
||||
const chinaMapRef = ref<HTMLElement | null>(null)
|
||||
const chartInstance = shallowRef<echarts.ECharts | null>(null)
|
||||
const settingStore = useSettingStore()
|
||||
const { isDark } = storeToRefs(settingStore)
|
||||
|
||||
// 默认地图数据
|
||||
const defaultMapJson = {
|
||||
type: 'FeatureCollection' as const,
|
||||
features: []
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<MapChartProps>(), {
|
||||
mapData: () => [],
|
||||
selectedRegion: '',
|
||||
showLabels: true,
|
||||
showScatter: true,
|
||||
isEmpty: false
|
||||
})
|
||||
|
||||
// 地图GeoJSON数据
|
||||
const mapJsonData = ref<{ type: 'FeatureCollection'; features: unknown[] }>(defaultMapJson)
|
||||
|
||||
// 定义 emit
|
||||
const emit = defineEmits<{
|
||||
renderComplete: []
|
||||
regionClick: [region: { name: string; adcode: string; level: string }]
|
||||
}>()
|
||||
|
||||
// 检查是否为空数据
|
||||
const isEmpty = computed(() => {
|
||||
return props.isEmpty || (!props.mapData?.length && !mapJsonData.value.features.length)
|
||||
})
|
||||
|
||||
// 获取地图数据
|
||||
const fetchMapData = async () => {
|
||||
try {
|
||||
const { data } = await fetchGetChinaMapData()
|
||||
if (data && data.features && data.features.length > 0) {
|
||||
mapJsonData.value = data as { type: 'FeatureCollection'; features: unknown[] }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取地图数据失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 根据 geoJson 数据准备地图数据
|
||||
const prepareMapData = (geoJson: {
|
||||
features: Array<{ properties: Record<string, unknown> }>
|
||||
}) => {
|
||||
return geoJson.features.map((feature) => ({
|
||||
name: feature.properties.name as string,
|
||||
value: Math.round(Math.random() * 1000),
|
||||
adcode: feature.properties.adcode as string,
|
||||
level: feature.properties.level as string,
|
||||
selected: false
|
||||
}))
|
||||
}
|
||||
|
||||
// 获取主题相关的样式配置
|
||||
const getThemeStyles = () => ({
|
||||
borderColor: isDark.value ? 'rgba(255,255,255,0.6)' : 'rgba(147,235,248,1)',
|
||||
shadowColor: isDark.value ? 'rgba(0,0,0,0.8)' : 'rgba(128,217,248,1)',
|
||||
labelColor: isDark.value ? '#fff' : '#333',
|
||||
backgroundColor: isDark.value ? 'rgba(0,0,0,0.8)' : 'rgba(255,255,255,0.9)'
|
||||
})
|
||||
|
||||
// 构造 ECharts 配置项
|
||||
const createChartOption = (mapData: Array<Record<string, unknown>>) => {
|
||||
const themeStyles = getThemeStyles()
|
||||
|
||||
return {
|
||||
animation: false, // 关闭动画效果,减少鼠标移动高亮时的掉帧感
|
||||
tooltip: {
|
||||
show: true,
|
||||
backgroundColor: themeStyles.backgroundColor,
|
||||
borderColor: isDark.value ? '#333' : '#ddd',
|
||||
borderWidth: 1,
|
||||
textStyle: {
|
||||
color: themeStyles.labelColor
|
||||
},
|
||||
formatter: ({ data }: { data?: Record<string, unknown> }) => {
|
||||
const { name, adcode, level } = data || {}
|
||||
return `
|
||||
<div style="padding: 8px;">
|
||||
<div><strong>名称:</strong> ${name || '未知区域'}</div>
|
||||
<div><strong>代码:</strong> ${adcode || '暂无'}</div>
|
||||
<div><strong>级别:</strong> ${level || '暂无'}</div>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
},
|
||||
geo: {
|
||||
map: 'china',
|
||||
zoom: 1,
|
||||
show: true,
|
||||
roam: false,
|
||||
scaleLimit: {
|
||||
min: 0.8,
|
||||
max: 3
|
||||
},
|
||||
layoutSize: '100%',
|
||||
emphasis: {
|
||||
label: { show: props.showLabels },
|
||||
itemStyle: {
|
||||
areaColor: 'rgba(82,180,255,0.9)',
|
||||
borderColor: '#fff',
|
||||
borderWidth: 3
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
borderColor: themeStyles.borderColor,
|
||||
borderWidth: 2,
|
||||
shadowColor: themeStyles.shadowColor,
|
||||
shadowOffsetX: 2,
|
||||
shadowOffsetY: 15,
|
||||
shadowBlur: 15
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'map',
|
||||
map: 'china',
|
||||
aspectScale: 0.75,
|
||||
zoom: 1,
|
||||
label: {
|
||||
show: props.showLabels,
|
||||
color: '#fff',
|
||||
fontSize: 10
|
||||
},
|
||||
itemStyle: {
|
||||
borderColor: 'rgba(147,235,248,0.8)',
|
||||
borderWidth: 2,
|
||||
areaColor: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: 'rgba(147,235,248,0.3)' },
|
||||
{ offset: 1, color: 'rgba(32,120,207,0.9)' }
|
||||
]
|
||||
},
|
||||
shadowColor: 'rgba(32,120,207,1)',
|
||||
shadowOffsetY: 15,
|
||||
shadowBlur: 20
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
color: '#fff',
|
||||
fontSize: 12
|
||||
},
|
||||
itemStyle: {
|
||||
areaColor: 'rgba(82,180,255,0.9)',
|
||||
borderColor: '#fff',
|
||||
borderWidth: 3
|
||||
}
|
||||
},
|
||||
select: {
|
||||
label: {
|
||||
show: true,
|
||||
color: '#fff',
|
||||
fontWeight: 'bold'
|
||||
},
|
||||
itemStyle: {
|
||||
areaColor: '#4FAEFB',
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
}
|
||||
},
|
||||
data: mapData
|
||||
},
|
||||
// 散点标记配置(例如:城市标记)
|
||||
...(props.showScatter
|
||||
? [
|
||||
{
|
||||
name: '城市',
|
||||
type: 'scatter',
|
||||
coordinateSystem: 'geo',
|
||||
symbol: 'pin',
|
||||
symbolSize: 15,
|
||||
label: { show: false },
|
||||
itemStyle: {
|
||||
color: '#F99020',
|
||||
shadowBlur: 10,
|
||||
shadowColor: '#333'
|
||||
},
|
||||
data: [
|
||||
{ name: '北京', value: [116.405285, 39.904989, 100] },
|
||||
{ name: '上海', value: [121.472644, 31.231706, 100] },
|
||||
{ name: '深圳', value: [114.085947, 22.547, 100] }
|
||||
]
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化并渲染地图
|
||||
const initMap = async (): Promise<void> => {
|
||||
if (!chinaMapRef.value) return
|
||||
|
||||
chartInstance.value = echarts.init(chinaMapRef.value)
|
||||
|
||||
// 注册地图
|
||||
const mapData = mapJsonData.value.features.length > 0 ? mapJsonData.value : defaultMapJson
|
||||
echarts.registerMap('china', mapData as any)
|
||||
|
||||
const preparedData = props.mapData.length > 0 ? props.mapData : prepareMapData(mapData as any)
|
||||
const option = createChartOption(preparedData)
|
||||
|
||||
chartInstance.value.setOption(option)
|
||||
|
||||
// 绑定事件
|
||||
chartInstance.value.on('click', handleMapClick)
|
||||
|
||||
emit('renderComplete')
|
||||
}
|
||||
|
||||
// 处理地图点击事件
|
||||
const handleMapClick = (params: Record<string, unknown>) => {
|
||||
if (params.componentType === 'series') {
|
||||
const data = params.data as Record<string, unknown> | undefined
|
||||
const regionData = {
|
||||
name: params.name as string,
|
||||
adcode: (data?.adcode as string) || '',
|
||||
level: (data?.level as string) || ''
|
||||
}
|
||||
|
||||
console.log(`选中区域: ${params.name}`, params)
|
||||
|
||||
// 高亮选中区域
|
||||
chartInstance.value?.dispatchAction({
|
||||
type: 'select',
|
||||
seriesIndex: 0,
|
||||
dataIndex: params.dataIndex as number
|
||||
})
|
||||
|
||||
emit('regionClick', regionData)
|
||||
}
|
||||
}
|
||||
|
||||
// 窗口 resize 时调整图表大小
|
||||
const resizeChart = () => {
|
||||
chartInstance.value?.resize()
|
||||
}
|
||||
|
||||
// 处理组件销毁
|
||||
const cleanupChart = () => {
|
||||
if (chartInstance.value) {
|
||||
chartInstance.value.off('click', handleMapClick)
|
||||
chartInstance.value.dispose()
|
||||
chartInstance.value = null
|
||||
}
|
||||
window.removeEventListener('resize', resizeChart)
|
||||
}
|
||||
|
||||
// 生命周期钩子
|
||||
onMounted(async () => {
|
||||
await fetchMapData()
|
||||
if (!isEmpty.value) {
|
||||
initMap().then(() => {
|
||||
setTimeout(resizeChart, 100)
|
||||
})
|
||||
}
|
||||
window.addEventListener('resize', resizeChart)
|
||||
})
|
||||
|
||||
onUnmounted(cleanupChart)
|
||||
|
||||
// 监听主题变化,重新初始化地图
|
||||
watch(isDark, (newVal, oldVal) => {
|
||||
if (newVal !== oldVal && chartInstance.value) {
|
||||
cleanupChart()
|
||||
nextTick(() => {
|
||||
if (!isEmpty.value) {
|
||||
initMap()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 监听数据变化
|
||||
watch(
|
||||
() => props.mapData,
|
||||
() => {
|
||||
if (chartInstance.value && !isEmpty.value) {
|
||||
const mapData = props.mapData.length > 0 ? props.mapData : prepareMapData(mapJsonData.value as any)
|
||||
const option = createChartOption(mapData)
|
||||
chartInstance.value.setOption(option)
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
// 监听地图数据变化
|
||||
watch(
|
||||
mapJsonData,
|
||||
() => {
|
||||
if (chartInstance.value && !isEmpty.value) {
|
||||
const mapData = props.mapData.length > 0 ? props.mapData : prepareMapData(mapJsonData.value as any)
|
||||
const option = createChartOption(mapData)
|
||||
chartInstance.value.setOption(option)
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
</script>
|
||||
@@ -83,9 +83,9 @@
|
||||
opacity: 1
|
||||
}"
|
||||
>
|
||||
<template v-if="AppConfig.systemInfo.name === '中科兴皖一体化门户'">
|
||||
<span class="system-name-main">中科兴皖</span>
|
||||
<span class="system-name-accent">一体化门户</span>
|
||||
<template v-if="AppConfig.systemInfo.name === '陇耘鲜达'">
|
||||
<span class="system-name-main">陇耘</span>
|
||||
<span class="system-name-accent">鲜达</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ AppConfig.systemInfo.name }}
|
||||
|
||||
@@ -38,7 +38,7 @@ import { headerBarConfig } from './modules/headerBar'
|
||||
const appConfig: SystemConfig = {
|
||||
// 系统信息
|
||||
systemInfo: {
|
||||
name: '中科兴皖一体化门户' // 系统名称
|
||||
name: '陇耘鲜达' // 系统名称
|
||||
},
|
||||
// 系统主题
|
||||
systemThemeStyles: {
|
||||
@@ -128,9 +128,7 @@ const appConfig: SystemConfig = {
|
||||
// 快速入口配置
|
||||
fastEnter: fastEnterConfig,
|
||||
// 顶部栏功能配置
|
||||
headerBar: headerBarConfig,
|
||||
/** 纯样式骨架:不接后端业务接口 */
|
||||
stylePreviewOnly: true
|
||||
headerBar: headerBarConfig
|
||||
}
|
||||
|
||||
export default Object.freeze(appConfig)
|
||||
@@ -1,125 +1,37 @@
|
||||
/**
|
||||
* 快速入口配置
|
||||
* 包含:应用列表、快速链接等配置
|
||||
* 快速入口配置(已裁剪为当前工程实际存在的路由)
|
||||
*/
|
||||
import { WEB_LINKS } from '@/utils/constants'
|
||||
import type { FastEnterConfig } from '@/types/config'
|
||||
|
||||
const fastEnterConfig: FastEnterConfig = {
|
||||
// 显示条件(屏幕宽度)
|
||||
minWidth: 1200,
|
||||
// 应用列表
|
||||
applications: [
|
||||
{
|
||||
name: '工作台',
|
||||
description: '系统概览与数据统计',
|
||||
description: '入口与参考页跳转',
|
||||
icon: 'ri:pie-chart-line',
|
||||
iconColor: '#377dff',
|
||||
iconColor: '#10b981',
|
||||
enabled: true,
|
||||
order: 1,
|
||||
routeName: 'Console'
|
||||
},
|
||||
{
|
||||
name: '分析页',
|
||||
description: '数据分析与可视化',
|
||||
icon: 'ri:game-line',
|
||||
iconColor: '#ff3b30',
|
||||
enabled: true,
|
||||
order: 2,
|
||||
routeName: 'Analysis'
|
||||
},
|
||||
{
|
||||
name: '礼花效果',
|
||||
description: '动画特效展示',
|
||||
icon: 'ri:loader-line',
|
||||
iconColor: '#7A7FFF',
|
||||
enabled: true,
|
||||
order: 3,
|
||||
routeName: 'Fireworks'
|
||||
},
|
||||
{
|
||||
name: '聊天',
|
||||
description: '即时通讯功能',
|
||||
icon: 'ri:user-line',
|
||||
iconColor: '#13DEB9',
|
||||
enabled: true,
|
||||
order: 4,
|
||||
routeName: 'Chat'
|
||||
},
|
||||
{
|
||||
name: '官方文档',
|
||||
description: '使用指南与开发文档',
|
||||
icon: 'ri:bill-line',
|
||||
iconColor: '#ffb100',
|
||||
enabled: true,
|
||||
order: 5,
|
||||
order: 2,
|
||||
link: WEB_LINKS.DOCS
|
||||
},
|
||||
{
|
||||
name: '技术支持',
|
||||
description: '技术支持与问题反馈',
|
||||
icon: 'ri:user-location-line',
|
||||
iconColor: '#ff6b6b',
|
||||
enabled: true,
|
||||
order: 6,
|
||||
link: WEB_LINKS.COMMUNITY
|
||||
},
|
||||
{
|
||||
name: '更新日志',
|
||||
description: '版本更新与变更记录',
|
||||
icon: 'ri:gamepad-line',
|
||||
iconColor: '#38C0FC',
|
||||
enabled: true,
|
||||
order: 7,
|
||||
routeName: 'ChangeLog'
|
||||
},
|
||||
{
|
||||
name: '哔哩哔哩',
|
||||
description: '技术分享与交流',
|
||||
icon: 'ri:bilibili-line',
|
||||
iconColor: '#FB7299',
|
||||
enabled: true,
|
||||
order: 8,
|
||||
link: WEB_LINKS.BILIBILI
|
||||
}
|
||||
],
|
||||
// 快速链接
|
||||
quickLinks: [
|
||||
{
|
||||
name: '登录',
|
||||
enabled: true,
|
||||
order: 1,
|
||||
routeName: 'Login'
|
||||
},
|
||||
{
|
||||
name: '注册',
|
||||
enabled: true,
|
||||
order: 2,
|
||||
routeName: 'Register'
|
||||
},
|
||||
{
|
||||
name: '忘记密码',
|
||||
enabled: true,
|
||||
order: 3,
|
||||
routeName: 'ForgetPassword'
|
||||
},
|
||||
{
|
||||
name: '定价',
|
||||
enabled: true,
|
||||
order: 4,
|
||||
routeName: 'Pricing'
|
||||
},
|
||||
{
|
||||
name: '个人中心',
|
||||
enabled: true,
|
||||
order: 5,
|
||||
routeName: 'UserCenter'
|
||||
},
|
||||
{
|
||||
name: '留言管理',
|
||||
enabled: true,
|
||||
order: 6,
|
||||
routeName: 'ArticleComment'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import '@styles/index.scss' // 样式
|
||||
import '@utils/sys/console.ts' // 控制台输出内容
|
||||
import { setupGlobDirectives } from './directives'
|
||||
import { setupErrorHandle } from './utils/sys/error-handle'
|
||||
import AppConfig from './config'
|
||||
import { useUserStore } from './store/modules/user'
|
||||
|
||||
function maskSecret(value?: string) {
|
||||
if (!value) return '(empty)'
|
||||
@@ -49,23 +47,6 @@ logApiCryptoBootInfo()
|
||||
|
||||
const app = createApp(App)
|
||||
initStore(app)
|
||||
|
||||
if (AppConfig.stylePreviewOnly) {
|
||||
const u = useUserStore()
|
||||
u.setLoginStatus(true)
|
||||
u.setToken('style-preview-token', 'style-preview-refresh')
|
||||
u.setUserInfo({
|
||||
id: '0',
|
||||
username: 'style-preview',
|
||||
realName: '样式预览',
|
||||
role: 'super_admin',
|
||||
phone: '',
|
||||
regionId: '',
|
||||
regionName: '',
|
||||
isActive: true
|
||||
} as Api.Auth.UserInfo)
|
||||
}
|
||||
|
||||
initRouter(app)
|
||||
setupGlobDirectives(app)
|
||||
setupErrorHandle(app)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import type { AppRouteRecord } from '@/types/router'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { useAppMode } from '@/hooks/core/useAppMode'
|
||||
import { fetchGetMenuList } from '@/api/system-manage'
|
||||
import { fetchGetMenuList } from '@/api/admin'
|
||||
import { fetchGetMenuCodes } from '@/api/auth'
|
||||
import { asyncRoutes } from '../routes/asyncRoutes'
|
||||
import { RoutesAlias } from '../routesAlias'
|
||||
|
||||
@@ -52,7 +52,6 @@ import { fetchGetUserInfo } from '@/api/auth'
|
||||
import { ApiStatus } from '@/utils/http/status'
|
||||
import { isHttpError } from '@/utils/http/error'
|
||||
import { RouteRegistry, MenuProcessor, IframeRouteManager, RoutePermissionValidator } from '../core'
|
||||
import AppConfig from '@/config'
|
||||
|
||||
// 路由注册器实例
|
||||
let routeRegistry: RouteRegistry | null = null
|
||||
@@ -207,11 +206,6 @@ function handleLoginStatus(
|
||||
userStore: ReturnType<typeof useUserStore>,
|
||||
next: NavigationGuardNext
|
||||
): boolean {
|
||||
// 纯样式骨架:不校验登录态
|
||||
if (AppConfig.stylePreviewOnly) {
|
||||
return true
|
||||
}
|
||||
|
||||
// 已登录或访问登录页或静态路由,直接放行
|
||||
if (userStore.isLogin || to.path === RoutesAlias.Login || isStaticRoute(to.path)) {
|
||||
return true
|
||||
@@ -272,10 +266,8 @@ async function handleDynamicRoutes(
|
||||
loadingService.showLoading()
|
||||
|
||||
try {
|
||||
// 1. 获取用户信息(样式骨架模式跳过接口)
|
||||
if (!AppConfig.stylePreviewOnly) {
|
||||
await fetchUserInfo()
|
||||
}
|
||||
// 1. 获取用户信息
|
||||
await fetchUserInfo()
|
||||
|
||||
// 2. 获取菜单数据
|
||||
const menuList = await menuProcessor.getMenuList()
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
import { AppRouteRecord } from '@/types/router'
|
||||
|
||||
export const articleRoutes: AppRouteRecord = {
|
||||
path: '/article',
|
||||
name: 'Article',
|
||||
component: '/index/index',
|
||||
meta: {
|
||||
title: 'menus.article.title',
|
||||
icon: 'ri:book-2-line',
|
||||
roles: ['R_SUPER', 'R_ADMIN']
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'article-list',
|
||||
name: 'ArticleList',
|
||||
component: '/article/list',
|
||||
meta: {
|
||||
title: 'menus.article.articleList',
|
||||
icon: 'ri:article-line',
|
||||
keepAlive: true,
|
||||
authList: [
|
||||
{ title: '新增', authMark: 'add' },
|
||||
{ title: '编辑', authMark: 'edit' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'detail/:id',
|
||||
name: 'ArticleDetail',
|
||||
component: '/article/detail',
|
||||
meta: {
|
||||
title: 'menus.article.articleDetail',
|
||||
isHide: true,
|
||||
keepAlive: true,
|
||||
activePath: '/article/article-list'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'comment',
|
||||
name: 'ArticleComment',
|
||||
component: '/article/comment',
|
||||
meta: {
|
||||
title: 'menus.article.comment',
|
||||
icon: 'ri:mail-line',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'publish',
|
||||
name: 'ArticlePublish',
|
||||
component: '/article/publish',
|
||||
meta: {
|
||||
title: 'menus.article.articlePublish',
|
||||
icon: 'ri:telegram-2-line',
|
||||
keepAlive: true,
|
||||
authList: [{ title: '发布', authMark: 'add' }]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import { AppRouteRecord } from '@/types/router'
|
||||
import { WEB_LINKS } from '@/utils/constants'
|
||||
|
||||
export const helpRoutes: AppRouteRecord[] = [
|
||||
{
|
||||
name: 'Document',
|
||||
path: '',
|
||||
component: '',
|
||||
meta: {
|
||||
title: 'menus.help.document',
|
||||
icon: 'ri:bill-line',
|
||||
link: WEB_LINKS.DOCS,
|
||||
isIframe: false,
|
||||
keepAlive: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'LiteVersion',
|
||||
path: '',
|
||||
component: '',
|
||||
meta: {
|
||||
title: 'menus.help.liteVersion',
|
||||
icon: 'ri:bus-2-line',
|
||||
link: WEB_LINKS.LiteVersion,
|
||||
isIframe: false,
|
||||
keepAlive: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'OldVersion',
|
||||
path: '',
|
||||
component: '',
|
||||
meta: {
|
||||
title: 'menus.help.oldVersion',
|
||||
icon: 'ri:subway-line',
|
||||
link: WEB_LINKS.OldVersion,
|
||||
isIframe: false,
|
||||
keepAlive: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'ChangeLog',
|
||||
path: '/change/log',
|
||||
component: '/change/log/index',
|
||||
meta: {
|
||||
title: 'menus.plan.log',
|
||||
showTextBadge: `v${__APP_VERSION__}`,
|
||||
icon: 'ri:gamepad-line',
|
||||
keepAlive: false
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1,7 +1,8 @@
|
||||
import { AppRouteRecord } from '@/types/router'
|
||||
import { styleReferenceRoutes } from './style-reference'
|
||||
import { sqxpAdminRoutes } from './sqxp'
|
||||
|
||||
/**
|
||||
* 动态路由(纯样式骨架:无业务菜单)
|
||||
* 动态菜单与路由(前端权限模式 VITE_ACCESS_MODE=frontend 时使用)
|
||||
* 陇耘鲜达业务菜单,与 backend/app/api/menu.py 中 get_admin_menu_list 对齐
|
||||
*/
|
||||
export const routeModules: AppRouteRecord[] = [...styleReferenceRoutes]
|
||||
export const routeModules: AppRouteRecord[] = [...sqxpAdminRoutes]
|
||||
@@ -1,33 +0,0 @@
|
||||
import { AppRouteRecord } from '@/types/router'
|
||||
|
||||
export const resultRoutes: AppRouteRecord = {
|
||||
path: '/result',
|
||||
name: 'Result',
|
||||
component: '/index/index',
|
||||
meta: {
|
||||
title: 'menus.result.title',
|
||||
icon: 'ri:checkbox-circle-line'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'success',
|
||||
name: 'ResultSuccess',
|
||||
component: '/result/success/index',
|
||||
meta: {
|
||||
title: 'menus.result.success',
|
||||
icon: 'ri:checkbox-circle-line',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'fail',
|
||||
name: 'ResultFail',
|
||||
component: '/result/fail/index',
|
||||
meta: {
|
||||
title: 'menus.result.fail',
|
||||
icon: 'ri:close-circle-line',
|
||||
keepAlive: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { AppRouteRecord } from '@/types/router'
|
||||
|
||||
export const safeguardRoutes: AppRouteRecord = {
|
||||
path: '/safeguard',
|
||||
name: 'Safeguard',
|
||||
component: '/index/index',
|
||||
meta: {
|
||||
title: 'menus.safeguard.title',
|
||||
icon: 'ri:shield-check-line',
|
||||
keepAlive: false
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'server',
|
||||
name: 'SafeguardServer',
|
||||
component: '/safeguard/server/index',
|
||||
meta: {
|
||||
title: 'menus.safeguard.server',
|
||||
icon: 'ri:hard-drive-3-line',
|
||||
keepAlive: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import type { AppRouteRecord } from '@/types/router'
|
||||
|
||||
/**
|
||||
* 前端路由(Demo 参考页 + 系统管理)
|
||||
* 与后端菜单对齐时请同步 `backend/app/api/menu.py`。
|
||||
*/
|
||||
export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
{
|
||||
id: '10000000000000000000000000000002',
|
||||
name: 'Demo',
|
||||
path: '/demo',
|
||||
component: '/index/index',
|
||||
meta: {
|
||||
title: 'Demo',
|
||||
icon: 'ri:layout-grid-line',
|
||||
keepAlive: false,
|
||||
roles: ['admin']
|
||||
},
|
||||
children: [
|
||||
{
|
||||
id: '10000000000000000000000000000001_child',
|
||||
name: 'Console',
|
||||
path: 'console',
|
||||
component: '/dashboard/console/index',
|
||||
meta: {
|
||||
title: '工作台',
|
||||
icon: 'ri:home-smile-2-line',
|
||||
keepAlive: true,
|
||||
fixedTab: true,
|
||||
menuCode: 'dashboard'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '10000000000000000000000000000005',
|
||||
name: 'Unit',
|
||||
path: 'unit',
|
||||
component: '/system/unit/index',
|
||||
meta: { title: '商品单位', keepAlive: true }
|
||||
},
|
||||
{
|
||||
id: '10000000000000000000000000000021',
|
||||
name: 'OrderList',
|
||||
path: 'order',
|
||||
component: '/system/order/index',
|
||||
meta: { title: '订单列表', keepAlive: true }
|
||||
},
|
||||
{
|
||||
id: '10000000000000000000000000000006',
|
||||
name: 'Product',
|
||||
path: 'product',
|
||||
component: '/system/product/index',
|
||||
meta: { title: '商品管理', keepAlive: true }
|
||||
},
|
||||
{
|
||||
id: '10000000000000000000000000000004',
|
||||
name: 'Category',
|
||||
path: 'category',
|
||||
component: '/system/category/index',
|
||||
meta: { title: '商品分类', keepAlive: true }
|
||||
},
|
||||
{
|
||||
id: '10000000000000000000000000000007',
|
||||
name: 'User',
|
||||
path: 'user',
|
||||
component: '/system/user/index',
|
||||
meta: { title: '用户管理', keepAlive: true }
|
||||
},
|
||||
{
|
||||
id: '10000000000000000000000000000008',
|
||||
name: 'UserDetail',
|
||||
path: 'user/detail',
|
||||
component: '/system/user/detail',
|
||||
meta: { title: '用户详情', isHide: true, keepAlive: true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: '20000000000000000000000000000001',
|
||||
name: 'System',
|
||||
path: '/system',
|
||||
component: '/index/index',
|
||||
meta: {
|
||||
title: '系统管理',
|
||||
icon: 'ri:settings-3-line',
|
||||
keepAlive: false,
|
||||
roles: ['admin']
|
||||
},
|
||||
children: [
|
||||
{
|
||||
id: '20000000000000000000000000000002',
|
||||
name: 'Tenant',
|
||||
path: 'tenant',
|
||||
component: '/system/tenant/index',
|
||||
meta: { title: '租户管理', keepAlive: true }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,47 +0,0 @@
|
||||
import type { AppRouteRecord } from '@/types/router'
|
||||
|
||||
/**
|
||||
* 仅保留界面样式参考:Mint 列表演示、登录区布局、Token 面板
|
||||
*/
|
||||
export const styleReferenceRoutes: AppRouteRecord[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'StylePreview',
|
||||
path: '/preview',
|
||||
component: '/index/index',
|
||||
meta: {
|
||||
title: '样式参考',
|
||||
icon: 'ri:palette-line',
|
||||
keepAlive: false,
|
||||
roles: ['admin']
|
||||
},
|
||||
children: [
|
||||
{
|
||||
id: 2,
|
||||
name: 'MintListDemo',
|
||||
path: 'mint-list',
|
||||
component: '/style-reference/delivery-demo/index',
|
||||
meta: {
|
||||
title: 'Mint 列表骨架',
|
||||
keepAlive: true,
|
||||
fixedTab: true,
|
||||
menuCode: 'dashboard'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'LoginSample',
|
||||
path: 'login-sample',
|
||||
component: '/style-reference/login-sample/index',
|
||||
meta: { title: '登录页样式', keepAlive: false }
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'MintTokens',
|
||||
path: 'mint-tokens',
|
||||
component: '/style-reference/mint-tokens/index',
|
||||
meta: { title: 'Mint Token 面板', keepAlive: false }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,15 +1,41 @@
|
||||
import { AppRouteRecordRaw } from '@/utils/router'
|
||||
|
||||
/**
|
||||
* 静态路由(样式骨架:无登录/注册页)
|
||||
* 静态路由配置(不需要权限就能访问的路由)
|
||||
*
|
||||
* 属性说明:
|
||||
* isHideTab: true 表示不在标签页中显示
|
||||
*
|
||||
* 注意事项:
|
||||
* 1、path、name 不要和动态路由冲突,否则会导致路由冲突无法访问
|
||||
* 2、静态路由不管是否登录都可以访问
|
||||
*/
|
||||
export const staticRoutes: AppRouteRecordRaw[] = [
|
||||
// 不需要登录就能访问的路由示例
|
||||
// {
|
||||
// path: '/welcome',
|
||||
// name: 'WelcomeStatic',
|
||||
// component: () => import('@views/dashboard/console/index.vue'),
|
||||
// meta: { title: 'menus.dashboard.title' }
|
||||
// },
|
||||
{
|
||||
path: '/auth/login',
|
||||
name: 'Login',
|
||||
component: () => import('@views/auth/login/index.vue'),
|
||||
meta: { title: 'menus.login.title', isHideTab: true }
|
||||
},
|
||||
{
|
||||
path: '/403',
|
||||
name: 'Exception403',
|
||||
component: () => import('@views/exception/403/index.vue'),
|
||||
meta: { title: '403', isHideTab: true }
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'Exception404',
|
||||
component: () => import('@views/exception/404/index.vue'),
|
||||
meta: { title: '404', isHideTab: true }
|
||||
},
|
||||
{
|
||||
path: '/500',
|
||||
name: 'Exception500',
|
||||
@@ -17,9 +43,18 @@ export const staticRoutes: AppRouteRecordRaw[] = [
|
||||
meta: { title: '500', isHideTab: true }
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'Exception404',
|
||||
component: () => import('@views/exception/404/index.vue'),
|
||||
meta: { title: '404', isHideTab: true }
|
||||
path: '/outside',
|
||||
component: () => import('@views/index/index.vue'),
|
||||
name: 'Outside',
|
||||
meta: { title: 'menus.outside.title' },
|
||||
children: [
|
||||
// iframe 内嵌页面
|
||||
{
|
||||
path: '/outside/iframe/:path',
|
||||
name: 'Iframe',
|
||||
component: () => import('@/views/outside/Iframe.vue'),
|
||||
meta: { title: 'iframe' }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -91,10 +91,10 @@ export const useWorktabStore = defineStore(
|
||||
|
||||
/**
|
||||
* 过滤不应展示在 worktab 中的父级占位路由。
|
||||
* `/dashboard` 仅用于承载与重定向,真实标签页应为 `/dashboard/console`。
|
||||
* `/demo` 仅用于承载与重定向,真实标签页为其子路由(如 `/demo/console`)。
|
||||
*/
|
||||
const shouldIgnoreTab = (tab: Partial<WorkTab>): boolean => {
|
||||
return tab.path === '/dashboard'
|
||||
return tab.path === '/demo' || tab.path === '/system'
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+15
-1
@@ -14,7 +14,7 @@ declare namespace Api {
|
||||
regionName?: string
|
||||
email?: string
|
||||
roles?: string[]
|
||||
/** 自定义头像 URL,空则前端使用系统默认 logo */
|
||||
/** 自定义头像 URL,空则前端使用叁强 logo */
|
||||
avatarUrl?: string | null
|
||||
}
|
||||
|
||||
@@ -92,6 +92,20 @@ declare namespace Api {
|
||||
}
|
||||
}
|
||||
|
||||
namespace Tenant {
|
||||
interface TenantItem {
|
||||
id: string
|
||||
tenantNo: string
|
||||
tenantName: string
|
||||
contactName: string
|
||||
contactPhone: string
|
||||
orderNum: number
|
||||
remark: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
}
|
||||
|
||||
namespace Product {
|
||||
interface ProductItem {
|
||||
id: string
|
||||
|
||||
@@ -144,8 +144,6 @@ export interface SystemConfig {
|
||||
fastEnter?: FastEnterConfig
|
||||
// 顶部栏功能配置
|
||||
headerBar?: HeaderBarFeatureConfig
|
||||
/** 仅保留界面样式参考:跳过登录与后端菜单/用户信息请求 */
|
||||
stylePreviewOnly?: boolean
|
||||
}
|
||||
|
||||
// 环境配置
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** 未设置头像时统一使用系统默认 logo(与登录页、侧栏 ArtLogo 一致) */
|
||||
/** 未设置头像时统一使用叁强 logo(与登录页、侧栏 ArtLogo 一致) */
|
||||
export const DEFAULT_USER_AVATAR_URL = '/logo1.jpg'
|
||||
|
||||
/** @deprecated 各角色默认已统一为 logo,保留参数仅为兼容旧调用 */
|
||||
@@ -6,7 +6,7 @@ export function defaultAvatarPathByRole(_role: string | undefined): string {
|
||||
return DEFAULT_USER_AVATAR_URL
|
||||
}
|
||||
|
||||
/** 展示用头像:有自定义 URL 用自定义,否则用系统默认 logo */
|
||||
/** 展示用头像:有自定义 URL 用自定义,否则用叁强 logo */
|
||||
export function resolveUserAvatarUrl(avatarUrl: string | null | undefined, role: string | undefined): string {
|
||||
const u = avatarUrl != null ? String(avatarUrl).trim() : ''
|
||||
if (u) return u
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
<!-- 登录页面 -->
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<!-- 左侧品牌区域 -->
|
||||
<div class="login-left">
|
||||
<div class="brand-content">
|
||||
<div class="logo">
|
||||
<img class="logo-img" src="/logo1.jpg" alt="陇耘鲜达" />
|
||||
</div>
|
||||
<h1 class="slogan">专业生鲜配送管理平台</h1>
|
||||
<p class="description">
|
||||
高效 · 智能 · 可信赖
|
||||
</p>
|
||||
<div class="features">
|
||||
<div class="feature-item">
|
||||
<i class="el-icon-present"></i>
|
||||
<span>订单管理</span>
|
||||
</div>
|
||||
<div class="feature-item">
|
||||
<i class="el-icon-truck"></i>
|
||||
<span>配送调度</span>
|
||||
</div>
|
||||
<div class="feature-item">
|
||||
<i class="el-icon-data-analysis"></i>
|
||||
<span>数据统计</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧登录表单区域 -->
|
||||
<div class="login-right">
|
||||
<div class="form-container">
|
||||
<div class="form-header">
|
||||
<h2>欢迎登录</h2>
|
||||
<p>请输入您的账号信息</p>
|
||||
</div>
|
||||
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="rules"
|
||||
@keyup.enter="handleSubmit"
|
||||
class="login-form"
|
||||
>
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
v-model.trim="formData.username"
|
||||
placeholder="请输入用户名"
|
||||
size="large"
|
||||
:prefix-icon="User"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="password">
|
||||
<el-input
|
||||
v-model.trim="formData.password"
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
size="large"
|
||||
:prefix-icon="Lock"
|
||||
show-password
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="large"
|
||||
:loading="loading"
|
||||
class="login-btn"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
登 录
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="form-footer">
|
||||
<span class="copyright">陇耘鲜达 © {{ currentYear }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { fetchLogin } from '@/api/auth'
|
||||
import { ElNotification, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { User, Lock } from '@element-plus/icons-vue'
|
||||
|
||||
defineOptions({ name: 'Login' })
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const formData = reactive({
|
||||
username: '',
|
||||
password: ''
|
||||
})
|
||||
|
||||
const rules: FormRules = {
|
||||
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
// 登录
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
|
||||
try {
|
||||
const valid = await formRef.value.validate()
|
||||
if (!valid) return
|
||||
|
||||
loading.value = true
|
||||
|
||||
const { token, refreshToken, userInfo } = await fetchLogin({
|
||||
username: formData.username,
|
||||
password: formData.password
|
||||
})
|
||||
|
||||
if (!token) {
|
||||
throw new Error('登录失败:未收到令牌')
|
||||
}
|
||||
|
||||
// 存储 token 和登录状态
|
||||
userStore.setToken(token, refreshToken)
|
||||
userStore.setLoginStatus(true)
|
||||
userStore.setUserInfo(userInfo)
|
||||
|
||||
ElNotification({
|
||||
title: '登录成功',
|
||||
type: 'success',
|
||||
duration: 2500,
|
||||
message: `欢迎回来,${userInfo.realName || userInfo.username}!`
|
||||
})
|
||||
|
||||
// 获取 redirect 参数,如果存在则跳转到指定页面,否则跳转到首页
|
||||
const redirect = route.query.redirect as string
|
||||
router.push(redirect || '/')
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '登录失败,请稍后重试')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.login-container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.login-left {
|
||||
flex: 1;
|
||||
background: linear-gradient(135deg, #1989fa 0%, #07c160 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.brand-content {
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
.logo-img {
|
||||
width: min(200px, 55vw);
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-size: 32px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 18px;
|
||||
opacity: 0.9;
|
||||
margin: 0 0 48px 0;
|
||||
}
|
||||
|
||||
.features {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
.feature-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
i {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 14px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
.login-right {
|
||||
width: 480px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #fff;
|
||||
padding: 40px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.form-container {
|
||||
width: 100%;
|
||||
max-width: 360px;
|
||||
}
|
||||
|
||||
.form-header {
|
||||
margin-bottom: 40px;
|
||||
text-align: center;
|
||||
|
||||
h2 {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin: 0 0 12px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.login-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
:deep(.el-input__wrapper) {
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
:deep(.el-input__inner) {
|
||||
height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
font-size: 16px;
|
||||
border-radius: 8px;
|
||||
background: linear-gradient(135deg, #1989fa 0%, #07c160 100%);
|
||||
border: none;
|
||||
|
||||
&:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
.form-footer {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
|
||||
.copyright {
|
||||
font-size: 12px;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
@reference '@styles/core/tailwind.css';
|
||||
|
||||
/* 授权页右侧区域 */
|
||||
.auth-right-wrap {
|
||||
@apply absolute inset-0 w-[440px] h-[650px] py-[5px] m-auto overflow-hidden
|
||||
max-sm:px-7 max-sm:w-full
|
||||
animate-[slideInRight_0.6s_cubic-bezier(0.25,0.46,0.45,0.94)_forwards]
|
||||
max-md:animate-none;
|
||||
|
||||
.form {
|
||||
@apply h-full py-[40px];
|
||||
}
|
||||
|
||||
.title {
|
||||
@apply text-g-900 text-4xl font-semibold max-md:text-3xl max-sm:pt-10;
|
||||
}
|
||||
|
||||
.sub-title {
|
||||
@apply mt-[10px] text-g-600 text-sm;
|
||||
}
|
||||
|
||||
.custom-height {
|
||||
@apply !h-[40px];
|
||||
}
|
||||
}
|
||||
|
||||
/* 滑入动画 */
|
||||
@keyframes slideInRight {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(30px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<!-- 精简工作台:无业务统计接口,仅作入口与 UI 规范说明 -->
|
||||
<template>
|
||||
<div class="console-container console-lite">
|
||||
<div class="page-head">
|
||||
<h1>工作台</h1>
|
||||
<p class="page-desc">以下为固定参考页,新增管理端界面请对照布局与类名;视觉以文档为准。</p>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">快速入口</h2>
|
||||
</div>
|
||||
<div class="console-lite__body">
|
||||
<p class="console-lite__hint">详见仓库根目录 `.cursorrules` 中「页面级 UI 模板(固定五页)」。</p>
|
||||
<div class="console-lite__links">
|
||||
<el-button
|
||||
v-for="item in links"
|
||||
:key="item.path"
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
@click="go(item.path)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
defineOptions({ name: 'Console' })
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const links = [
|
||||
{ label: '商品单位', path: '/demo/unit' },
|
||||
{ label: '订单列表', path: '/demo/order' },
|
||||
{ label: '商品管理', path: '/demo/product' },
|
||||
{ label: '商品分类', path: '/demo/category' },
|
||||
{ label: '用户管理', path: '/demo/user' }
|
||||
]
|
||||
|
||||
const go = (path: string) => {
|
||||
router.push(path)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.console-lite__body {
|
||||
padding: 20px 24px 24px;
|
||||
}
|
||||
|
||||
.console-lite__hint {
|
||||
margin: 0 0 16px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--art-text-gray-600, #64748b);
|
||||
}
|
||||
|
||||
.console-lite__links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,36 +1,42 @@
|
||||
<!-- 外链 iframe 占位(动态路由中 isIframe 时使用) -->
|
||||
<template>
|
||||
<div class="iframe-page">
|
||||
<iframe v-if="src" class="iframe-page__frame" :src="src" title="external" />
|
||||
<p v-else class="iframe-page__empty">未配置链接</p>
|
||||
<div class="box-border w-full h-full" v-loading="isLoading">
|
||||
<iframe
|
||||
ref="iframeRef"
|
||||
:src="iframeUrl"
|
||||
frameborder="0"
|
||||
class="w-full h-full min-h-[calc(100vh-120px)] border-none"
|
||||
@load="handleIframeLoad"
|
||||
></iframe>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { IframeRouteManager } from '@/router/core'
|
||||
|
||||
defineOptions({ name: 'IframePage' })
|
||||
defineOptions({ name: 'IframeView' })
|
||||
|
||||
const route = useRoute()
|
||||
const src = computed(() => (route.meta?.link as string) || '')
|
||||
const isLoading = ref(true)
|
||||
const iframeUrl = ref('')
|
||||
const iframeRef = ref<HTMLIFrameElement | null>(null)
|
||||
|
||||
/**
|
||||
* 初始化 iframe URL
|
||||
* 从路由配置中获取对应的外部链接地址
|
||||
*/
|
||||
onMounted(() => {
|
||||
const iframeRoute = IframeRouteManager.getInstance().findByPath(route.path)
|
||||
|
||||
if (iframeRoute?.meta) {
|
||||
iframeUrl.value = iframeRoute.meta.link || ''
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 处理 iframe 加载完成事件
|
||||
* 隐藏加载状态
|
||||
*/
|
||||
const handleIframeLoad = (): void => {
|
||||
isLoading.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.iframe-page {
|
||||
height: 100%;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
.iframe-page__frame {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 400px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.iframe-page__empty {
|
||||
padding: 24px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,205 +0,0 @@
|
||||
<!-- 登录页布局样式参考(不请求后端) -->
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<div class="login-left">
|
||||
<div class="brand-content">
|
||||
<div class="logo">
|
||||
<img class="logo-img" src="/logo1.jpg" alt="中科兴皖一体化门户" />
|
||||
</div>
|
||||
<h1 class="slogan">一体化业务管理与服务平台</h1>
|
||||
<p class="description">本页仅作布局与配色参考</p>
|
||||
<div class="features">
|
||||
<div class="feature-item"><span>面板</span></div>
|
||||
<div class="feature-item"><span>表格</span></div>
|
||||
<div class="feature-item"><span>表单</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-right">
|
||||
<div class="form-container">
|
||||
<div class="form-header">
|
||||
<h2>欢迎登录</h2>
|
||||
<p>演示表单,提交不会调用接口</p>
|
||||
</div>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" class="login-form">
|
||||
<el-form-item prop="username">
|
||||
<el-input v-model.trim="formData.username" placeholder="用户名" size="large" :prefix-icon="User" />
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-input
|
||||
v-model.trim="formData.password"
|
||||
type="password"
|
||||
placeholder="密码"
|
||||
size="large"
|
||||
:prefix-icon="Lock"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="large" class="login-btn" @click="onSubmit">登 录</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="form-footer">
|
||||
<span class="copyright">中科兴皖一体化门户 © {{ currentYear }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { User, Lock } from '@element-plus/icons-vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
defineOptions({ name: 'LoginSample' })
|
||||
|
||||
const currentYear = new Date().getFullYear()
|
||||
const formRef = ref<FormInstance>()
|
||||
const formData = reactive({ username: '', password: '' })
|
||||
const rules: FormRules = {
|
||||
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const onSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
await formRef.value.validate().catch(() => {})
|
||||
ElMessage.info('样式参考页:未连接后端')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.login-container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.login-left {
|
||||
flex: 1;
|
||||
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.brand-content {
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
.logo-img {
|
||||
width: min(200px, 55vw);
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-size: 32px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 16px;
|
||||
opacity: 0.95;
|
||||
margin: 0 0 48px 0;
|
||||
}
|
||||
|
||||
.features {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
.feature-item span {
|
||||
font-size: 14px;
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
.login-right {
|
||||
width: 480px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #fff;
|
||||
padding: 40px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.form-container {
|
||||
width: 100%;
|
||||
max-width: 360px;
|
||||
}
|
||||
|
||||
.form-header {
|
||||
margin-bottom: 40px;
|
||||
text-align: center;
|
||||
|
||||
h2 {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin: 0 0 12px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.login-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
:deep(.el-input__wrapper) {
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
:deep(.el-input__inner) {
|
||||
height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
font-size: 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.form-footer {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
|
||||
.copyright {
|
||||
font-size: 12px;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,98 +0,0 @@
|
||||
<!-- Fresh Mint 设计 Token 与面板片段参考(无接口) -->
|
||||
<template>
|
||||
<div class="page-container mint-tokens-page">
|
||||
<header class="page-head">
|
||||
<h1>Mint Token 与面板</h1>
|
||||
<p class="page-desc">与全局 SCSS 变量、Element 主色链对齐的局部示意,便于新页面拷贝结构。</p>
|
||||
</header>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">色板</h2>
|
||||
</div>
|
||||
<div class="token-grid">
|
||||
<div v-for="t in tokens" :key="t.name" class="token-card">
|
||||
<div class="token-swatch" :style="{ background: t.value }" />
|
||||
<div class="token-meta">
|
||||
<div class="token-name">{{ t.name }}</div>
|
||||
<div class="token-value">{{ t.value }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">按钮</h2>
|
||||
</div>
|
||||
<div class="btn-row">
|
||||
<el-button type="primary">主按钮</el-button>
|
||||
<el-button>次要</el-button>
|
||||
<el-button plain>描边</el-button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({ name: 'MintTokensSample' })
|
||||
|
||||
const tokens = [
|
||||
{ name: '--primary', value: '#10b981' },
|
||||
{ name: '--primary-dark', value: '#059669' },
|
||||
{ name: '--primary-bg', value: '#ecfdf5' },
|
||||
{ name: '--text', value: '#1e293b' },
|
||||
{ name: '--text-muted', value: '#64748b' },
|
||||
{ name: '--border', value: '#d9e8e2' }
|
||||
]
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.mint-tokens-page {
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
|
||||
.token-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.token-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--default-border-color, #d9e8e2);
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.token-swatch {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(0, 0, 0, 0.06);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.token-name {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.token-value {
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
font-family: ui-monospace, monospace;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
padding: 16px;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,327 @@
|
||||
<!-- 租户管理(系统管理) -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<header class="page-head">
|
||||
<h1>租户管理</h1>
|
||||
<p class="page-desc">维护多租户编号与名称;编号「{{ DEFAULT_TENANT_NO }}」为平台默认租户,不可删除且不可改编号。</p>
|
||||
</header>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">租户列表</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="关键词">
|
||||
<el-input v-model="searchForm.keyword" placeholder="租户编号/名称" clearable />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">按租户编号、名称模糊查询。</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" @click="handleReset">重置</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleSearch">搜索</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新增租户
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
type="danger"
|
||||
:disabled="deletableSelection.length === 0"
|
||||
@click="handleBatchDelete"
|
||||
>
|
||||
批量删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="tableData"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" header-align="center" :selectable="rowSelectable" />
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column prop="tenantNo" label="租户编号" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.tenantNo }}</span>
|
||||
<el-tag v-if="isDefaultTenantRow(row)" class="tag muted" size="small" style="margin-left: 8px">默认</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="tenantName" label="租户名称" min-width="160" align="center" header-align="center" />
|
||||
<el-table-column prop="contactName" label="联系人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column prop="contactPhone" label="联系电话" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="orderNum" label="排序" width="80" align="center" header-align="center" />
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="160" align="center" header-align="center" />
|
||||
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button class="btn-op-item" :disabled="isDefaultTenantRow(row)" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
:current-page="pagination.page"
|
||||
:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
|
||||
@current-change="(val) => ((pagination.page = val), loadData())"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="560px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="tenant-dialog-form"
|
||||
scroll-to-error
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="租户编号" prop="tenantNo">
|
||||
<el-input
|
||||
v-model="formData.tenantNo"
|
||||
placeholder="业务唯一编码,如 demo01"
|
||||
:disabled="isEdit && isDefaultTenantNo(formData.tenantNo)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="租户名称" prop="tenantName">
|
||||
<el-input v-model="formData.tenantName" placeholder="展示名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系人">
|
||||
<el-input v-model="formData.contactName" placeholder="可选" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系电话">
|
||||
<el-input v-model="formData.contactPhone" placeholder="可选" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序">
|
||||
<div class="sort-field">
|
||||
<el-input-number v-model="formData.orderNum" :min="0" :max="9999" controls-position="right" />
|
||||
<span class="form-tip">数值越小越靠前</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" style="grid-column: 1 / -1">
|
||||
<el-input v-model="formData.remark" type="textarea" :rows="2" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogVisible = false">
|
||||
<el-icon><Close /></el-icon>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleSubmit" :loading="submitLoading">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Plus, Close, Check } from '@element-plus/icons-vue'
|
||||
import { fetchTenantList, fetchCreateTenant, fetchUpdateTenant, fetchDeleteTenant } from '@/api/admin'
|
||||
|
||||
/** 与后端 `settings.DEFAULT_TENANT_NO` 一致 */
|
||||
const DEFAULT_TENANT_NO = 'zkxw'
|
||||
|
||||
defineOptions({ name: 'SystemTenant' })
|
||||
|
||||
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
|
||||
const tableData = ref<Api.Tenant.TenantItem[]>([])
|
||||
const selectedRows = ref<Api.Tenant.TenantItem[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增租户')
|
||||
const isEdit = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const formRef = ref()
|
||||
const editingId = ref<string | null>(null)
|
||||
|
||||
const formData = reactive({
|
||||
tenantNo: '',
|
||||
tenantName: '',
|
||||
contactName: '',
|
||||
contactPhone: '',
|
||||
orderNum: 0,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
tenantNo: [{ required: true, message: '请输入租户编号', trigger: 'blur' }],
|
||||
tenantName: [{ required: true, message: '请输入租户名称', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const deletableSelection = computed(() => selectedRows.value.filter((r) => !isDefaultTenantRow(r)))
|
||||
|
||||
function isDefaultTenantNo(no: string) {
|
||||
return (no || '').trim() === DEFAULT_TENANT_NO
|
||||
}
|
||||
|
||||
function isDefaultTenantRow(row: Api.Tenant.TenantItem) {
|
||||
return isDefaultTenantNo(row.tenantNo)
|
||||
}
|
||||
|
||||
function rowSelectable(row: Api.Tenant.TenantItem) {
|
||||
return !isDefaultTenantRow(row)
|
||||
}
|
||||
|
||||
const handleSelectionChange = (rows: Api.Tenant.TenantItem[]) => {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchTenantList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined
|
||||
})
|
||||
tableData.value = res.list || []
|
||||
pagination.total = res.total ?? 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.keyword = ''
|
||||
pagination.page = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formData.tenantNo = ''
|
||||
formData.tenantName = ''
|
||||
formData.contactName = ''
|
||||
formData.contactPhone = ''
|
||||
formData.orderNum = 0
|
||||
formData.remark = ''
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
isEdit.value = false
|
||||
dialogTitle.value = '新增租户'
|
||||
resetForm()
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
function handleEdit(row: Api.Tenant.TenantItem) {
|
||||
isEdit.value = true
|
||||
dialogTitle.value = '编辑租户'
|
||||
editingId.value = row.id
|
||||
formData.tenantNo = row.tenantNo
|
||||
formData.tenantName = row.tenantName
|
||||
formData.contactName = row.contactName || ''
|
||||
formData.contactPhone = row.contactPhone || ''
|
||||
formData.orderNum = row.orderNum ?? 0
|
||||
formData.remark = row.remark || ''
|
||||
dialogVisible.value = true
|
||||
formRef.value?.clearValidate?.()
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate?.()
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const payload = {
|
||||
tenantNo: formData.tenantNo.trim(),
|
||||
tenantName: formData.tenantName.trim(),
|
||||
contactName: formData.contactName?.trim() || undefined,
|
||||
contactPhone: formData.contactPhone?.trim() || undefined,
|
||||
orderNum: formData.orderNum,
|
||||
remark: formData.remark?.trim() || undefined
|
||||
}
|
||||
if (isEdit.value && editingId.value) {
|
||||
await fetchUpdateTenant(editingId.value, payload)
|
||||
} else {
|
||||
await fetchCreateTenant(payload)
|
||||
}
|
||||
dialogVisible.value = false
|
||||
await loadData()
|
||||
} catch {
|
||||
/* 校验或接口错误已由全局处理 */
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: Api.Tenant.TenantItem) {
|
||||
if (isDefaultTenantRow(row)) {
|
||||
ElMessage.warning('默认租户不可删除')
|
||||
return
|
||||
}
|
||||
await ElMessageBox.confirm(`确定删除租户「${row.tenantName}」吗?`, '提示', { type: 'warning' })
|
||||
await fetchDeleteTenant(row.id)
|
||||
await loadData()
|
||||
}
|
||||
|
||||
async function handleBatchDelete() {
|
||||
const ids = deletableSelection.value.map((r) => r.id)
|
||||
if (!ids.length) {
|
||||
ElMessage.warning('所选中含默认租户或无可删项,请重新选择')
|
||||
return
|
||||
}
|
||||
await ElMessageBox.confirm(`确定删除选中的 ${ids.length} 个租户吗?`, '提示', { type: 'warning' })
|
||||
for (const id of ids) {
|
||||
await fetchDeleteTenant(id)
|
||||
}
|
||||
selectedRows.value = []
|
||||
await loadData()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.tenant-dialog-form {
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,434 @@
|
||||
<!-- 商品单位管理 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<header class="page-head">
|
||||
<h1>单位管理</h1>
|
||||
<p class="page-desc">统一维护商品计量单位与排序规则。</p>
|
||||
</header>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">单位列表</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="关键词">
|
||||
<el-input v-model="searchForm.keyword" placeholder="单位名称/编码" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="searchForm.isActive" placeholder="请选择状态" clearable>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="启用" :value="true" />
|
||||
<el-option label="禁用" :value="false" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">按名称、编码与状态过滤单位数据。</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" @click="handleReset">重置</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleSearch">搜索</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="handleAdd"><el-icon><Plus /></el-icon>新增单位</el-button>
|
||||
|
||||
<el-button class="btn-ghost" type="danger" :disabled="selectedRows.length === 0" @click="handleBatchDelete">
|
||||
批量删除
|
||||
</el-button>
|
||||
|
||||
<ArtExcelExport
|
||||
:data="batchExportData"
|
||||
:list-total="pagination.total"
|
||||
:load-all-data="loadAllUnitsForExport"
|
||||
:filename="unitExportFilename"
|
||||
sheetName="单位数据"
|
||||
:columns="unitExportColumns"
|
||||
>
|
||||
批量导出
|
||||
</ArtExcelExport>
|
||||
|
||||
<ArtExcelExport
|
||||
:data="unitImportTemplateData"
|
||||
:filename="unitImportTemplateFilename"
|
||||
sheetName="单位导入模板"
|
||||
:columns="unitImportTemplateColumns"
|
||||
:showSuccessMessage="false"
|
||||
:showErrorMessage="false"
|
||||
>
|
||||
下载导入模板
|
||||
</ArtExcelExport>
|
||||
|
||||
<ArtExcelImport @import-success="handleUnitImportSuccess" @import-error="handleExcelImportError">
|
||||
<el-button class="btn-ghost">批量导入</el-button>
|
||||
</ArtExcelImport>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-body list-wrap">
|
||||
<el-table class="list-table" :data="tableData" v-loading="loading" stripe row-key="id" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:index="index => (pagination.page - 1) * pagination.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column prop="name" label="单位名称" min-width="150" align="center" header-align="center" />
|
||||
<el-table-column prop="code" label="单位编码" min-width="120" align="center" header-align="center" />
|
||||
<el-table-column prop="isActive" label="状态" min-width="80" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.isActive ? 'success' : 'info'" size="small">{{ row.isActive ? '启用' : '禁用' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="排序号" width="90" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
{{ row.sortOrder ?? row.sort_order ?? 0 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="260" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item primary" @click="handleEdit(row)">编辑</el-button>
|
||||
<el-button class="btn-op-item" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
:current-page="pagination.page"
|
||||
:page-size="pagination.pageSize"
|
||||
:total="pagination.total"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
@size-change="val => (pagination.page = 1, pagination.pageSize = val, loadData())"
|
||||
@current-change="val => (pagination.page = val, loadData())"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="560px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
class="unit-dialog-form"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="单位名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="如:斤、kg、个" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单位编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="如:jin、kg、ge" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序">
|
||||
<div class="sort-field">
|
||||
<el-input-number v-model="formData.sortOrder" :min="0" :max="9999" controls-position="right" />
|
||||
<span class="form-tip">数值越小越靠前</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" v-if="isEdit"><el-switch v-model="formData.isActive" /></el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogVisible = false">
|
||||
<el-icon><Close /></el-icon>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="handleSubmit" :loading="submitLoading">
|
||||
<el-icon><Check /></el-icon>
|
||||
确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import { Plus, Close, Check } from '@element-plus/icons-vue'
|
||||
import { fetchUnitList, fetchCreateUnit, fetchUpdateUnit, fetchDeleteUnit } from '../../../api/admin'
|
||||
import { fetchNextSortOrder } from '../../../utils/sort-order'
|
||||
import { fetchAllPagedRecords } from '../../../utils/fetch-paged-list'
|
||||
defineOptions({ name: 'ProductUnit' })
|
||||
const searchForm = reactive<{ keyword: string; isActive: boolean | '' }>({ keyword: '', isActive: '' })
|
||||
const tableData = ref<any[]>([])
|
||||
const selectedRows = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增单位')
|
||||
const isEdit = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const formRef = ref()
|
||||
const handleSelectionChange = (rows: any[]) => {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
const unitExportFilename = 'base_unit_batch_export'
|
||||
const unitImportTemplateFilename = 'base_unit_import_template'
|
||||
|
||||
const unitExportColumns = {
|
||||
id: { title: 'id' },
|
||||
name: { title: '单位名称' },
|
||||
code: { title: '单位编码' },
|
||||
sortOrder: { title: '排序' },
|
||||
isActive: { title: '状态' }
|
||||
} as const
|
||||
|
||||
const unitImportTemplateColumns = {
|
||||
id: { title: 'id' },
|
||||
name: { title: '单位名称' },
|
||||
code: { title: '单位编码' },
|
||||
sortOrder: { title: '排序' },
|
||||
isActive: { title: '状态' }
|
||||
} as const
|
||||
|
||||
const unitImportTemplateData = [
|
||||
{
|
||||
id: '',
|
||||
name: '',
|
||||
code: '',
|
||||
sortOrder: 0,
|
||||
isActive: true
|
||||
}
|
||||
]
|
||||
|
||||
const mapUnitExportRow = (row: any) => ({
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
code: row.code,
|
||||
sortOrder: row.sortOrder ?? row.sort_order ?? 0,
|
||||
isActive: row.isActive
|
||||
})
|
||||
|
||||
const batchExportData = computed(() => {
|
||||
const sel = selectedRows.value || []
|
||||
if (sel.length === 0) return []
|
||||
return sel.map(mapUnitExportRow)
|
||||
})
|
||||
|
||||
const loadAllUnitsForExport = async () => {
|
||||
const all = await fetchAllPagedRecords((page, pageSize) =>
|
||||
fetchUnitList({
|
||||
page,
|
||||
pageSize,
|
||||
keyword: searchForm.keyword || undefined,
|
||||
isActive: searchForm.isActive === '' ? undefined : searchForm.isActive
|
||||
})
|
||||
)
|
||||
return all.map(mapUnitExportRow)
|
||||
}
|
||||
|
||||
// ======================
|
||||
// 批量删除
|
||||
// ======================
|
||||
const handleBatchDelete = async () => {
|
||||
if (selectedRows.value.length === 0) return
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定要删除选中的 ${selectedRows.value.length} 条单位吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
|
||||
await withFullscreenLoading(async () => {
|
||||
for (const row of selectedRows.value) {
|
||||
await fetchDeleteUnit(row.id)
|
||||
}
|
||||
ElMessage.success('批量删除成功')
|
||||
selectedRows.value = []
|
||||
loadData()
|
||||
}, fullscreenLoadingText.batchDelete)
|
||||
} catch (error: any) {
|
||||
if (error !== 'cancel') console.error('批量删除失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// ======================
|
||||
// Excel 导入
|
||||
// ======================
|
||||
const importLoading = ref(false)
|
||||
|
||||
const parseNumber = (v: any, defaultValue: number) => {
|
||||
if (v === null || v === undefined || v === '') return defaultValue
|
||||
const n = Number(v)
|
||||
return Number.isFinite(n) ? n : defaultValue
|
||||
}
|
||||
|
||||
const parseBool = (v: any, defaultValue: boolean) => {
|
||||
if (v === null || v === undefined || v === '') return defaultValue
|
||||
if (typeof v === 'boolean') return v
|
||||
const s = String(v).trim().toLowerCase()
|
||||
if (['1', 'true', 'yes', '启用', 'enabled'].includes(s)) return true
|
||||
if (['0', 'false', 'no', '禁用', 'disabled'].includes(s)) return false
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
const getExcelValue = (row: any, keys: string[]) => {
|
||||
for (const k of keys) {
|
||||
const v = row?.[k]
|
||||
if (v !== undefined && v !== null && String(v).trim() !== '') return v
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
const handleExcelImportError = (error: Error) => {
|
||||
ElMessage.error(`导入失败:${error.message}`)
|
||||
}
|
||||
|
||||
const handleUnitImportSuccess = async (rows: Array<Record<string, unknown>>) => {
|
||||
if (importLoading.value) return
|
||||
importLoading.value = true
|
||||
|
||||
try {
|
||||
if (!Array.isArray(rows) || rows.length === 0) {
|
||||
ElMessage.warning('没有可导入的数据')
|
||||
return
|
||||
}
|
||||
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
|
||||
for (const raw of rows) {
|
||||
const id = String(getExcelValue(raw, ['id', 'ID']) ?? '').trim()
|
||||
const name = String(getExcelValue(raw, ['name', '单位名称']) ?? '').trim()
|
||||
const code = String(getExcelValue(raw, ['code', '单位编码']) ?? '').trim()
|
||||
const sortOrder = parseNumber(getExcelValue(raw, ['sortOrder', '排序', 'sort_order']) as any, 0)
|
||||
const isActive = parseBool(getExcelValue(raw, ['isActive', '状态', 'is_active']) as any, true)
|
||||
|
||||
if (!name || !code) {
|
||||
failCount++
|
||||
continue
|
||||
}
|
||||
|
||||
const payload: any = { name, code, sortOrder, isActive }
|
||||
|
||||
if (id) {
|
||||
await fetchUpdateUnit(id, payload)
|
||||
} else {
|
||||
await fetchCreateUnit(payload)
|
||||
}
|
||||
|
||||
successCount++
|
||||
}
|
||||
|
||||
ElMessage.success(`导入完成:成功 ${successCount} 条,失败 ${failCount} 条`)
|
||||
selectedRows.value = []
|
||||
loadData()
|
||||
} catch (error: any) {
|
||||
console.error('导入单位失败:', error)
|
||||
ElMessage.error(`导入单位失败:${error?.message || error}`)
|
||||
} finally {
|
||||
importLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const formData = reactive({ id: '', name: '', code: '', isActive: true, sortOrder: 0 })
|
||||
const formRules = {
|
||||
name: [{ required: true, message: '请输入单位名称', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '请输入单位编码', trigger: 'blur' }]
|
||||
}
|
||||
const loadData = async () => {
|
||||
selectedRows.value = []
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchUnitList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined,
|
||||
isActive: searchForm.isActive === '' ? undefined : searchForm.isActive
|
||||
})
|
||||
const list = res.list || []
|
||||
tableData.value = list.map((item: any) => ({
|
||||
...item,
|
||||
sortOrder: item.sortOrder ?? item.sort_order ?? 0
|
||||
}))
|
||||
pagination.total = res.total
|
||||
} catch (error) { console.error('加载数据失败:', error) } finally { loading.value = false }
|
||||
}
|
||||
const handleSearch = () => { pagination.page = 1; loadData() }
|
||||
const handleReset = () => { Object.assign(searchForm, { keyword: '', isActive: '' }); loadData() }
|
||||
const handleAdd = async () => {
|
||||
dialogTitle.value = '新增单位'
|
||||
isEdit.value = false
|
||||
const next = await fetchNextSortOrder(params =>
|
||||
fetchUnitList({ ...params, keyword: undefined, isActive: undefined })
|
||||
)
|
||||
Object.assign(formData, { id: '', name: '', code: '', isActive: true, sortOrder: next })
|
||||
dialogVisible.value = true
|
||||
}
|
||||
const handleEdit = (row: any) => { dialogTitle.value = '编辑单位'; isEdit.value = true; Object.assign(formData, row); dialogVisible.value = true }
|
||||
const handleDelete = async (row: any) => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要删除该单位吗?', '提示', { type: 'warning' })
|
||||
await withFullscreenLoading(async () => {
|
||||
await fetchDeleteUnit(row.id)
|
||||
}, fullscreenLoadingText.delete)
|
||||
ElMessage.success('删除成功')
|
||||
loadData()
|
||||
} catch (error: any) {
|
||||
if (error !== 'cancel') console.error('删除失败:', error)
|
||||
}
|
||||
}
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
submitLoading.value = true
|
||||
await withFullscreenLoading(async () => {
|
||||
if (isEdit.value) {
|
||||
const updateData: any = { name: formData.name, code: formData.code, sort_order: formData.sortOrder }
|
||||
updateData.is_active = formData.isActive
|
||||
await fetchUpdateUnit(formData.id, updateData)
|
||||
} else {
|
||||
await fetchCreateUnit({ name: formData.name, code: formData.code, sortOrder: formData.sortOrder, isActive: formData.isActive } as any)
|
||||
}
|
||||
ElMessage.success(isEdit.value ? '更新成功' : '创建成功')
|
||||
dialogVisible.value = false
|
||||
loadData()
|
||||
}, fullscreenLoadingText.save)
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error)
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
onMounted(() => loadData())
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.unit-dialog-form {
|
||||
:deep(.el-form-item__label) {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
color: var(--mint-text-muted);
|
||||
padding: 0 0 4px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
.form-grid-2 {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px 20px;
|
||||
}
|
||||
|
||||
.sort-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form-tip { margin-left: 8px; color: #909399; font-size: 12px; }
|
||||
</style>
|
||||
@@ -0,0 +1,797 @@
|
||||
<!-- 用户详情页面 -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<!-- 返回按钮 -->
|
||||
<div class="back-bar">
|
||||
<el-button @click="goBack" type="primary" plain>
|
||||
<el-icon><ArrowLeft /></el-icon>
|
||||
返回列表
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 基本信息卡片 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">基本信息</span>
|
||||
<div class="header-actions">
|
||||
<el-button @click="handleResetPassword" type="warning" size="small">重置密码</el-button>
|
||||
<el-button @click="handleToggleStatus" :type="userData.isActive ? 'danger' : 'success'" size="small">
|
||||
{{ userData.isActive ? '禁用账号' : '启用账号' }}
|
||||
</el-button>
|
||||
<el-button @click="handleEdit" type="primary" size="small">编辑</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户头像和信息 -->
|
||||
<div class="profile-section">
|
||||
<el-avatar :size="80" :src="detailAvatarUrl" class="detail-user-avatar">
|
||||
{{ getAvatarInitial }}
|
||||
</el-avatar>
|
||||
<div class="profile-info">
|
||||
<div class="profile-name">{{ userData.realName }}</div>
|
||||
<div class="profile-tags">
|
||||
<el-tag :type="getRoleTagType(userData.role)" size="small">{{ getRoleText(userData.role) }}</el-tag>
|
||||
<el-tag :type="userData.isActive ? 'success' : 'danger'" size="small">{{ userData.isActive ? '启用' : '禁用' }}</el-tag>
|
||||
<el-tag v-if="userData.regionName" size="small">{{ userData.regionName }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 基本信息网格 -->
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<div class="info-label">用户名</div>
|
||||
<div class="info-value">{{ userData.username }}</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label">姓名</div>
|
||||
<div class="info-value">{{ userData.realName }}</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label">手机号</div>
|
||||
<div class="info-value">{{ userData.phone }}</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label">角色</div>
|
||||
<div class="info-value">{{ getRoleText(userData.role) }}</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label">所属区域</div>
|
||||
<div class="info-value">{{ userData.regionName || '-' }}</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label">账号状态</div>
|
||||
<div class="info-value" :style="{ color: userData.isActive ? '#059669' : '#dc2626' }">
|
||||
{{ userData.isActive ? '正常' : '已禁用' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label">创建时间</div>
|
||||
<div class="info-value">{{ userData.createAt }}</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<div class="info-label">最后登录</div>
|
||||
<div class="info-value">{{ userData.lastLoginTime || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 供应商/客户专属信息 -->
|
||||
<div v-if="userData.role === 'supplier'" class="address-section">
|
||||
<div class="address-title">取货地址</div>
|
||||
<div class="address-row">
|
||||
<span class="address-label">联系人</span>
|
||||
<span class="address-value">{{ supplierData.contactPerson || '-' }}</span>
|
||||
</div>
|
||||
<div class="address-row">
|
||||
<span class="address-label">联系电话</span>
|
||||
<span class="address-value">{{ supplierData.contactPhone || '-' }}</span>
|
||||
</div>
|
||||
<div class="address-row">
|
||||
<span class="address-label">详细地址</span>
|
||||
<span class="address-value">{{ supplierData.address || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="userData.role === 'client'" class="address-section">
|
||||
<div class="address-title">
|
||||
<span>收货地址</span>
|
||||
<el-button @click="handleAddAddress" type="primary" link size="small">+ 添加地址</el-button>
|
||||
</div>
|
||||
<div v-if="clientAddresses.length > 0" class="address-list">
|
||||
<div v-for="addr in clientAddresses" :key="addr.id" class="address-item">
|
||||
<div class="address-info">
|
||||
<div class="address-contact">
|
||||
{{ addr.contactPerson }} {{ addr.contactPhone }}
|
||||
<el-tag v-if="addr.isDefault" size="small" type="success" class="ml-2">默认</el-tag>
|
||||
</div>
|
||||
<div class="address-detail">{{ addr.province }}{{ addr.city }}{{ addr.district }}{{ addr.detailAddress }}</div>
|
||||
</div>
|
||||
<div class="address-actions">
|
||||
<el-button type="primary" link @click="handleEditAddress(addr)">编辑</el-button>
|
||||
<el-button type="danger" link @click="handleDeleteAddress(addr)">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="暂无收货地址" :image-size="60" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 业务统计卡片 -->
|
||||
<div v-if="userData.role === 'supplier'" class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">业务统计</span>
|
||||
</div>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-num">{{ supplierStats.quotationCount }}</div>
|
||||
<div class="stat-label">报价次数</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-num">{{ supplierStats.selectedCount }}</div>
|
||||
<div class="stat-label">被选中次数</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-num">{{ supplierStats.orderCount }}</div>
|
||||
<div class="stat-label">供货订单数</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-num amount">¥{{ formatAmount(supplierStats.totalAmount) }}</div>
|
||||
<div class="stat-label">累计供货金额(元)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="userData.role === 'client'" class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">订单统计</span>
|
||||
</div>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-num">{{ clientStats.totalOrders }}</div>
|
||||
<div class="stat-label">总订单数</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-num">{{ clientStats.completedOrders }}</div>
|
||||
<div class="stat-label">已完成</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-num">{{ clientStats.pendingOrders }}</div>
|
||||
<div class="stat-label">进行中</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-num amount" style="color: #dc2626;">¥{{ formatAmount(clientStats.pendingAmount) }}</div>
|
||||
<div class="stat-label">待结算金额(元)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 登录记录 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">最近登录记录</span>
|
||||
</div>
|
||||
<el-table :data="loginLogs" stripe max-height="300">
|
||||
<el-table-column type="index" label="序号" width="68" align="center" header-align="center" :index="index => index + 1" />
|
||||
<el-table-column prop="loginTime" label="登录时间" min-width="180" />
|
||||
<el-table-column prop="ipAddress" label="IP地址" min-width="150" />
|
||||
<el-table-column prop="loginLocation" label="登录地点" min-width="150" />
|
||||
<el-table-column prop="device" label="设备" min-width="120" />
|
||||
<el-table-column prop="result" label="结果" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.result === 'success' ? 'success' : 'danger'" size="small">
|
||||
{{ row.result === 'success' ? '成功' : '失败' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="failReason" label="失败原因" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.result === 'fail'" style="color: #dc2626;">{{ row.failReason }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<!-- 编辑用户弹窗 -->
|
||||
<el-dialog v-model="editVisible" title="编辑用户" width="600px" destroy-on-close>
|
||||
<el-form ref="editFormRef" :model="editForm" :rules="editFormRules" label-width="100px">
|
||||
<el-form-item label="姓名" prop="realName">
|
||||
<el-input v-model="editForm.realName" placeholder="请输入姓名" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="editForm.phone" placeholder="请输入手机号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="所属区域" prop="regionId">
|
||||
<el-select v-model="editForm.regionId" placeholder="请选择区域">
|
||||
<el-option v-for="r in regionList" :key="r.id" :label="r.name" :value="r.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-switch v-model="editForm.isActive" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="editVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirmEdit" :loading="submitLoading">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 地址编辑弹窗 -->
|
||||
<el-dialog v-model="addressVisible" :title="addressForm.id ? '编辑地址' : '添加地址'" width="600px" destroy-on-close>
|
||||
<el-form ref="addressFormRef" :model="addressForm" :rules="addressFormRules" label-width="100px">
|
||||
<el-form-item label="联系人" prop="contactPerson">
|
||||
<el-input v-model="addressForm.contactPerson" placeholder="请输入联系人" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系电话" prop="contactPhone">
|
||||
<el-input v-model="addressForm.contactPhone" placeholder="请输入联系电话" />
|
||||
</el-form-item>
|
||||
<el-form-item label="省份" prop="province">
|
||||
<el-input v-model="addressForm.province" placeholder="请输入省份" />
|
||||
</el-form-item>
|
||||
<el-form-item label="城市" prop="city">
|
||||
<el-input v-model="addressForm.city" placeholder="请输入城市" />
|
||||
</el-form-item>
|
||||
<el-form-item label="区县" prop="district">
|
||||
<el-input v-model="addressForm.district" placeholder="请输入区县" />
|
||||
</el-form-item>
|
||||
<el-form-item label="详细地址" prop="detailAddress">
|
||||
<el-input v-model="addressForm.detailAddress" type="textarea" :rows="2" placeholder="请输入详细地址" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设为默认">
|
||||
<el-switch v-model="addressForm.isDefault" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="addressVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirmAddress" :loading="submitLoading">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted, watch } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import { fetchUserDetail, fetchUpdateUser, fetchActiveRegions } from '@/api/admin'
|
||||
import { resolveUserAvatarUrl } from '@/utils/user-avatar'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
defineOptions({ name: 'UserDetail' })
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
// 用户基本信息
|
||||
const userData = ref<any>({
|
||||
username: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
avatarUrl: '',
|
||||
role: '',
|
||||
regionName: '',
|
||||
isActive: true,
|
||||
createAt: '',
|
||||
lastLoginTime: ''
|
||||
})
|
||||
|
||||
// 供应商专属数据
|
||||
const supplierData = ref({
|
||||
contactPerson: '',
|
||||
contactPhone: '',
|
||||
address: ''
|
||||
})
|
||||
|
||||
const supplierStats = reactive({
|
||||
quotationCount: 0,
|
||||
selectedCount: 0,
|
||||
orderCount: 0,
|
||||
totalAmount: 0
|
||||
})
|
||||
|
||||
// 客户专属数据
|
||||
const clientAddresses = ref<any[]>([])
|
||||
|
||||
const clientStats = reactive({
|
||||
totalOrders: 0,
|
||||
completedOrders: 0,
|
||||
pendingOrders: 0,
|
||||
pendingAmount: 0
|
||||
})
|
||||
|
||||
// 登录记录
|
||||
const loginLogs = ref<any[]>([])
|
||||
|
||||
// 区域列表
|
||||
const regionList = ref<any[]>([])
|
||||
|
||||
// 编辑弹窗
|
||||
const editVisible = ref(false)
|
||||
const editFormRef = ref<FormInstance>()
|
||||
const submitLoading = ref(false)
|
||||
const editForm = reactive({
|
||||
id: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
regionId: '',
|
||||
isActive: true
|
||||
})
|
||||
|
||||
const editFormRules: FormRules = {
|
||||
realName: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
// 地址编辑弹窗
|
||||
const addressVisible = ref(false)
|
||||
const addressFormRef = ref<FormInstance>()
|
||||
const addressForm = reactive({
|
||||
id: '',
|
||||
contactPerson: '',
|
||||
contactPhone: '',
|
||||
province: '',
|
||||
city: '',
|
||||
district: '',
|
||||
detailAddress: '',
|
||||
isDefault: false
|
||||
})
|
||||
|
||||
const addressFormRules: FormRules = {
|
||||
contactPerson: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
|
||||
contactPhone: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
|
||||
detailAddress: [{ required: true, message: '请输入详细地址', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const detailAvatarUrl = computed(() =>
|
||||
resolveUserAvatarUrl(userData.value.avatarUrl, userData.value.role)
|
||||
)
|
||||
|
||||
const getAvatarInitial = computed(() => {
|
||||
return userData.value.realName?.charAt(0) || '?'
|
||||
})
|
||||
|
||||
// 获取角色相关
|
||||
const getRoleTagType = (role: string) => {
|
||||
const typeMap: Record<string, string> = {
|
||||
admin: 'primary',
|
||||
supplier: 'warning',
|
||||
client: 'success',
|
||||
deliver: 'info'
|
||||
}
|
||||
return typeMap[role] || 'info'
|
||||
}
|
||||
|
||||
const getRoleText = (role: string) => {
|
||||
const textMap: Record<string, string> = {
|
||||
admin: '运营管理员',
|
||||
supplier: '供应商',
|
||||
client: '客户',
|
||||
deliver: '配送员'
|
||||
}
|
||||
return textMap[role] || role
|
||||
}
|
||||
|
||||
// 格式化金额
|
||||
const formatAmount = (amount: number | string) => {
|
||||
const num = typeof amount === 'string' ? parseFloat(amount) : amount
|
||||
return isNaN(num) ? '0.00' : num.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
}
|
||||
|
||||
// 返回列表
|
||||
const goBack = () => {
|
||||
router.push('/demo/user')
|
||||
}
|
||||
|
||||
// 加载数据
|
||||
const loadData = async () => {
|
||||
const userId = route.query.id as string
|
||||
if (!userId) {
|
||||
ElMessage.error('用户ID不能为空')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetchUserDetail(userId)
|
||||
userData.value = {
|
||||
...res,
|
||||
regionName: res.regionName || (regionList.value.find(r => r.id === res.regionId)?.name || '')
|
||||
}
|
||||
|
||||
// 根据角色加载专属数据
|
||||
if (res.role === 'supplier') {
|
||||
supplierData.value = res.supplierInfo || {
|
||||
contactPerson: '张伟',
|
||||
contactPhone: '13800138001',
|
||||
address: '城东区XX路XX号 XX仓库'
|
||||
}
|
||||
supplierStats.quotationCount = res.quotationCount || 28
|
||||
supplierStats.selectedCount = res.selectedCount || 15
|
||||
supplierStats.orderCount = res.orderCount || 86
|
||||
supplierStats.totalAmount = res.totalAmount || 125680
|
||||
}
|
||||
|
||||
if (res.role === 'client') {
|
||||
clientAddresses.value = res.addresses || [
|
||||
{
|
||||
id: '1',
|
||||
contactPerson: '王小明',
|
||||
contactPhone: '13900009999',
|
||||
province: '浙江省',
|
||||
city: '杭州市',
|
||||
district: '西湖区',
|
||||
detailAddress: 'XX路XX号 XX餐厅',
|
||||
isDefault: true
|
||||
}
|
||||
]
|
||||
clientStats.totalOrders = res.totalOrders || 156
|
||||
clientStats.completedOrders = res.completedOrders || 128
|
||||
clientStats.pendingOrders = res.pendingOrders || 28
|
||||
clientStats.pendingAmount = res.pendingAmount || 12560
|
||||
}
|
||||
|
||||
// 加载登录记录
|
||||
loginLogs.value = res.loginLogs || [
|
||||
{ loginTime: '2026-03-19 09:15:30', ipAddress: '192.168.1.100', loginLocation: '浙江省杭州市', device: 'iOS', result: 'success' },
|
||||
{ loginTime: '2026-03-18 14:22:15', ipAddress: '192.168.1.100', loginLocation: '浙江省杭州市', device: 'Windows', result: 'success' },
|
||||
{ loginTime: '2026-03-17 08:45:00', ipAddress: '192.168.1.101', loginLocation: '浙江省杭州市', device: 'Android', result: 'fail', failReason: '密码错误' },
|
||||
{ loginTime: '2026-03-16 16:30:22', ipAddress: '192.168.1.100', loginLocation: '浙江省杭州市', device: 'Windows', result: 'success' }
|
||||
]
|
||||
} catch (error) {
|
||||
console.error('加载用户详情失败:', error)
|
||||
ElMessage.error('加载用户详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 加载区域
|
||||
const loadRegions = async () => {
|
||||
try {
|
||||
const res = await fetchActiveRegions()
|
||||
regionList.value = res
|
||||
} catch (error) {
|
||||
console.error('加载区域失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑用户
|
||||
const handleEdit = () => {
|
||||
editForm.id = userData.value.id
|
||||
editForm.realName = userData.value.realName
|
||||
editForm.phone = userData.value.phone
|
||||
editForm.regionId = userData.value.regionId
|
||||
editForm.isActive = userData.value.isActive
|
||||
editVisible.value = true
|
||||
}
|
||||
|
||||
const confirmEdit = async () => {
|
||||
if (!editFormRef.value) return
|
||||
try {
|
||||
await editFormRef.value.validate()
|
||||
submitLoading.value = true
|
||||
await withFullscreenLoading(async () => {
|
||||
await fetchUpdateUser(editForm.id, {
|
||||
realName: editForm.realName,
|
||||
phone: editForm.phone,
|
||||
regionId: editForm.regionId || undefined,
|
||||
isActive: editForm.isActive
|
||||
})
|
||||
ElMessage.success('更新成功')
|
||||
editVisible.value = false
|
||||
loadData()
|
||||
}, fullscreenLoadingText.save)
|
||||
} catch (error) {
|
||||
console.error('更新失败:', error)
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 重置密码
|
||||
const handleResetPassword = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要重置用户「${userData.value.realName}」的密码吗?重置后密码将恢复为默认密码。`,
|
||||
'重置密码',
|
||||
{
|
||||
confirmButtonText: '确认重置',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
ElMessage.success('密码已重置,默认密码为:123456')
|
||||
} catch (error) {
|
||||
// 取消操作
|
||||
}
|
||||
}
|
||||
|
||||
// 切换账号状态
|
||||
const handleToggleStatus = async () => {
|
||||
const action = userData.value.isActive ? '禁用' : '启用'
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要${action}用户「${userData.value.realName}」的账号吗?`,
|
||||
`${action}账号`,
|
||||
{
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: userData.value.isActive ? 'warning' : 'success'
|
||||
}
|
||||
)
|
||||
await withFullscreenLoading(async () => {
|
||||
await fetchUpdateUser(userData.value.id, { isActive: !userData.value.isActive })
|
||||
ElMessage.success(`${action}成功`)
|
||||
userData.value.isActive = !userData.value.isActive
|
||||
}, fullscreenLoadingText.save)
|
||||
} catch (error) {
|
||||
// 取消操作
|
||||
}
|
||||
}
|
||||
|
||||
// 添加地址
|
||||
const handleAddAddress = () => {
|
||||
addressForm.id = ''
|
||||
addressForm.contactPerson = ''
|
||||
addressForm.contactPhone = ''
|
||||
addressForm.province = ''
|
||||
addressForm.city = ''
|
||||
addressForm.district = ''
|
||||
addressForm.detailAddress = ''
|
||||
addressForm.isDefault = false
|
||||
addressVisible.value = true
|
||||
}
|
||||
|
||||
// 编辑地址
|
||||
const handleEditAddress = (addr: any) => {
|
||||
Object.assign(addressForm, addr)
|
||||
addressVisible.value = true
|
||||
}
|
||||
|
||||
// 删除地址
|
||||
const handleDeleteAddress = async (addr: any) => {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要删除该地址吗?', '删除地址', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
ElMessage.success('删除成功')
|
||||
clientAddresses.value = clientAddresses.value.filter(a => a.id !== addr.id)
|
||||
} catch (error) {
|
||||
// 取消操作
|
||||
}
|
||||
}
|
||||
|
||||
// 确认地址
|
||||
const confirmAddress = async () => {
|
||||
if (!addressFormRef.value) return
|
||||
try {
|
||||
await addressFormRef.value.validate()
|
||||
submitLoading.value = true
|
||||
if (addressForm.id) {
|
||||
const index = clientAddresses.value.findIndex(a => a.id === addressForm.id)
|
||||
if (index > -1) {
|
||||
clientAddresses.value[index] = { ...addressForm }
|
||||
}
|
||||
ElMessage.success('更新成功')
|
||||
} else {
|
||||
const newAddr = { ...addressForm, id: `addr_${Date.now()}` }
|
||||
clientAddresses.value.push(newAddr)
|
||||
ElMessage.success('添加成功')
|
||||
}
|
||||
addressVisible.value = false
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error)
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => editVisible.value,
|
||||
(visible) => {
|
||||
if (visible) void loadRegions()
|
||||
}
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
loadRegions()
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.back-bar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
|
||||
.card-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.profile-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
margin-bottom: 24px;
|
||||
padding: 20px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.detail-user-avatar {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.profile-info {
|
||||
flex: 1;
|
||||
|
||||
.profile-name {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.profile-tags {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
.info-label {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.address-section {
|
||||
margin-top: 20px;
|
||||
padding: 16px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 8px;
|
||||
|
||||
.address-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #606266;
|
||||
margin-bottom: 12px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.address-row {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
padding: 8px 0;
|
||||
font-size: 14px;
|
||||
|
||||
.address-label {
|
||||
color: #909399;
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
.address-value {
|
||||
color: #303133;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.address-list {
|
||||
.address-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.address-info {
|
||||
flex: 1;
|
||||
|
||||
.address-contact {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 4px;
|
||||
|
||||
.ml-2 {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.address-detail {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
|
||||
.address-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 16px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: #f5f7fa;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
|
||||
.stat-num {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #059669;
|
||||
|
||||
&.amount {
|
||||
font-size: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.ml-2 {
|
||||
margin-left: 8px;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<ElDialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogType === 'add' ? '添加用户' : '编辑用户'"
|
||||
width="720px"
|
||||
class="user-dialog"
|
||||
align-center
|
||||
>
|
||||
<ElForm ref="formRef" :model="formData" :rules="rules" label-position="top" class="user-form-grid">
|
||||
<ElFormItem label="用户名" prop="username">
|
||||
<ElInput v-model="formData.username" placeholder="请输入用户名" />
|
||||
</ElFormItem>
|
||||
<ElFormItem label="手机号" prop="phone">
|
||||
<ElInput v-model="formData.phone" placeholder="请输入手机号" />
|
||||
</ElFormItem>
|
||||
<ElFormItem label="性别" prop="gender">
|
||||
<ElSelect v-model="formData.gender">
|
||||
<ElOption label="男" value="男" />
|
||||
<ElOption label="女" value="女" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="角色" prop="role">
|
||||
<ElSelect v-model="formData.role" multiple>
|
||||
<ElOption
|
||||
v-for="role in roleList"
|
||||
:key="role.roleCode"
|
||||
:value="role.roleCode"
|
||||
:label="role.roleName"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<ElButton class="btn-ghost" @click="dialogVisible = false">取消</ElButton>
|
||||
<ElButton class="btn-main" type="primary" @click="handleSubmit">提交</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { fetchGetRoleList } from '@/api/admin'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
interface Props {
|
||||
visible: boolean
|
||||
type: string
|
||||
userData?: Partial<Api.SystemManage.UserListItem>
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:visible', value: boolean): void
|
||||
(e: 'submit'): void
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
// 角色列表数据
|
||||
const roleList = ref<Array<{ roleName: string; roleCode: string }>>([])
|
||||
|
||||
// 加载角色列表
|
||||
const loadRoleList = async () => {
|
||||
try {
|
||||
const roles = await fetchGetRoleList()
|
||||
roleList.value = roles.map((r: any) => ({
|
||||
roleName: r.label,
|
||||
roleCode: r.value
|
||||
}))
|
||||
} catch (error) {
|
||||
console.error('加载角色列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 对话框显示控制
|
||||
const dialogVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: (value) => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const dialogType = computed(() => props.type)
|
||||
|
||||
// 表单实例
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
username: '',
|
||||
phone: '',
|
||||
gender: '男',
|
||||
role: [] as string[]
|
||||
})
|
||||
|
||||
// 表单验证规则
|
||||
const rules: FormRules = {
|
||||
username: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号格式', trigger: 'blur' }
|
||||
],
|
||||
gender: [{ required: true, message: '请选择性别', trigger: 'blur' }],
|
||||
role: [{ required: true, message: '请选择角色', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化表单数据
|
||||
* 根据对话框类型(新增/编辑)填充表单
|
||||
*/
|
||||
const initFormData = () => {
|
||||
const isEdit = props.type === 'edit' && props.userData
|
||||
const row = props.userData
|
||||
|
||||
Object.assign(formData, {
|
||||
username: isEdit && row ? row.userName || '' : '',
|
||||
phone: isEdit && row ? row.userPhone || '' : '',
|
||||
gender: isEdit && row ? row.userGender || '男' : '男',
|
||||
role: isEdit && row ? (Array.isArray(row.userRoles) ? row.userRoles : []) : []
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听对话框状态变化
|
||||
* 当对话框打开时初始化表单数据并清除验证状态
|
||||
*/
|
||||
watch(
|
||||
() => [props.visible, props.type, props.userData],
|
||||
([visible]) => {
|
||||
if (visible) {
|
||||
void loadRoleList()
|
||||
initFormData()
|
||||
nextTick(() => {
|
||||
formRef.value?.clearValidate()
|
||||
})
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
/**
|
||||
* 提交表单
|
||||
* 验证通过后触发提交事件
|
||||
*/
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
|
||||
await formRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
ElMessage.success(dialogType.value === 'add' ? '添加成功' : '更新成功')
|
||||
dialogVisible.value = false
|
||||
emit('submit')
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.user-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px 20px;
|
||||
|
||||
:deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.user-form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<ArtSearchBar
|
||||
ref="searchBarRef"
|
||||
v-model="formData"
|
||||
:items="formItems"
|
||||
:rules="rules"
|
||||
@reset="handleReset"
|
||||
@search="handleSearch"
|
||||
>
|
||||
</ArtSearchBar>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Props {
|
||||
modelValue: Api.SystemManage.UserSearchParams
|
||||
}
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: Api.SystemManage.UserSearchParams): void
|
||||
(e: 'search', params: Api.SystemManage.UserSearchParams): void
|
||||
(e: 'reset'): void
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
// 表单数据双向绑定
|
||||
const searchBarRef = ref()
|
||||
const formData = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (val) => emit('update:modelValue', val)
|
||||
})
|
||||
|
||||
// 校验规则
|
||||
const rules = {
|
||||
// userName: [{ required: true, message: '请输入用户名', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
// 动态 options
|
||||
const statusOptions = ref<{ label: string; value: string; disabled?: boolean }[]>([])
|
||||
|
||||
// 模拟接口返回状态数据
|
||||
function fetchStatusOptions(): Promise<typeof statusOptions.value> {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve([
|
||||
{ label: '在线', value: '1' },
|
||||
{ label: '离线', value: '2' },
|
||||
{ label: '异常', value: '3' },
|
||||
{ label: '注销', value: '4' }
|
||||
])
|
||||
}, 1000)
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
statusOptions.value = await fetchStatusOptions()
|
||||
})
|
||||
|
||||
// 表单配置
|
||||
const formItems = computed(() => [
|
||||
{
|
||||
label: '用户名',
|
||||
key: 'userName',
|
||||
type: 'input',
|
||||
placeholder: '请输入用户名',
|
||||
clearable: true
|
||||
},
|
||||
{
|
||||
label: '手机号',
|
||||
key: 'userPhone',
|
||||
type: 'input',
|
||||
props: { placeholder: '请输入手机号', maxlength: '11' }
|
||||
},
|
||||
{
|
||||
label: '邮箱',
|
||||
key: 'userEmail',
|
||||
type: 'input',
|
||||
props: { placeholder: '请输入邮箱' }
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
key: 'status',
|
||||
type: 'select',
|
||||
props: {
|
||||
placeholder: '请选择状态',
|
||||
options: statusOptions.value
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '性别',
|
||||
key: 'userGender',
|
||||
type: 'radiogroup',
|
||||
props: {
|
||||
options: [
|
||||
{ label: '男', value: '1' },
|
||||
{ label: '女', value: '2' }
|
||||
]
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
// 事件
|
||||
function handleReset() {
|
||||
console.log('重置表单')
|
||||
emit('reset')
|
||||
}
|
||||
|
||||
async function handleSearch(params: Api.SystemManage.UserSearchParams) {
|
||||
await searchBarRef.value.validate()
|
||||
emit('search', params)
|
||||
console.log('表单数据', params)
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user