feat(product-center): implement Figma-designed UI, upload module, and website tests
- Redesign website homepage & product-center per Figma (fonts, logos, hero/footer/customer cases) - Add API upload module (multer) with static serving for uploads/public assets - Add OriginGood.delisted flag and SDS request retry logic - Add admin ImageUpload component and goods import/upload flows - Add vitest suite for website components and composables (32 tests) - Add skills, docs, plans and PRODUCT.md
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<svg preserveAspectRatio="xMidYMid meet" width="97" height="56" viewBox="0 0 97 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="Frame" clip-path="url(#clip0_0_30)">
|
||||
<g id="Group">
|
||||
<path id="Vector" d="M16.318 51.2332V53.8323C17.2443 53.6294 18.0909 53.4188 18.8525 53.1979L19.0969 54.0481C17.9416 54.3665 16.7117 54.6542 15.4072 54.9085L15.0341 54.1354C15.2683 54.0044 15.3866 53.8169 15.3866 53.5678V47.6478C16.632 47.4526 17.7486 47.1957 18.7341 46.8747L19.3105 47.617C18.4614 47.8918 17.463 48.1383 16.3155 48.3592V50.342H19.0171V51.2306H16.318V51.2332ZM21.4666 54.6131L21.2119 53.7142L22.0842 53.7347C22.3389 53.7347 22.465 53.5935 22.465 53.3135V48.2513H20.5378V55.9307H19.5986V47.373H23.4067V53.5087C23.4067 54.2458 23.0671 54.6131 22.3878 54.6131H21.4666Z" fill="var(--fill-0, #FF6902)"/>
|
||||
<path id="Vector_2" d="M34.4941 52.1013C34.4606 52.2965 34.4221 52.4788 34.3757 52.6483H38.0474V53.5267H34.8183C35.4847 54.2895 36.7275 54.8057 38.5466 55.0805L38.0577 55.9589C35.9633 55.548 34.5893 54.8032 33.9358 53.7219C33.7325 54.0737 33.4855 54.3794 33.1922 54.6414C32.5463 55.209 31.4142 55.6584 29.7958 55.9897L29.415 55.0805C30.8173 54.834 31.8233 54.477 32.4305 54.0147C32.6209 53.858 32.783 53.6962 32.9194 53.5267H29.8755V52.6483H33.398C33.4572 52.4583 33.5086 52.2451 33.5549 52.0037L34.4941 52.1013ZM29.9733 47.8224H32.078C31.9468 47.5219 31.8079 47.2548 31.6561 47.0211L32.6338 46.8644C32.7522 47.111 32.8808 47.432 33.0249 47.8224H34.9135C35.0627 47.4962 35.1785 47.1675 35.2557 46.8362L36.254 46.962C36.1691 47.2548 36.0508 47.5425 35.9015 47.8224H37.9368V48.6623H34.4272V49.4045H37.4222V50.2058H34.4272V50.9584H38.2636V51.8188H29.6491V50.9584H33.4855V50.2058H30.5188V49.4045H33.4855V48.6623H29.9707V47.8224H29.9733Z" fill="var(--fill-0, #FF6902)"/>
|
||||
<path id="Vector_3" d="M50.8993 55.756C50.5597 55.756 49.9525 55.7483 49.0776 55.7355C48.419 55.7278 47.876 55.6738 47.4541 55.5685C47.0372 55.4504 46.677 55.2244 46.3786 54.8853C46.2422 54.7235 46.111 54.6414 45.9875 54.6414C45.779 54.6414 45.4188 55.0934 44.9119 56L44.2275 55.3656C44.7241 54.5592 45.1692 54.0506 45.5681 53.8426V51.097H44.2378V50.1981H46.4609V53.9094C46.5123 53.9479 46.5612 53.9967 46.6076 54.0558C46.8623 54.3152 47.1093 54.5078 47.3512 54.6311C47.6522 54.7672 48.1076 54.8468 48.7226 54.8648C49.4919 54.8776 50.1763 54.8853 50.7784 54.8853L52.1395 54.8751C52.5898 54.8545 52.9449 54.8365 53.2073 54.816L52.9835 55.7534H50.8993V55.756ZM45.0174 47.0006C45.6838 47.5091 46.2473 48.0125 46.7105 48.5159L46.0261 49.199C45.635 48.7111 45.0869 48.182 44.3819 47.617L45.0174 47.0006ZM47.2096 49.0039H49.2938C49.3452 48.5338 49.3761 48.0561 49.3813 47.5682V46.9132H50.3101V47.3627C50.3101 47.9354 50.2818 48.4825 50.2226 49.0039H52.5718V49.9028H50.3899C50.7167 51.1073 51.5426 52.3221 52.8651 53.5472L52.2193 54.2304C51.0511 53.0644 50.2689 51.9189 49.8701 50.7914C49.4199 52.3221 48.6274 53.4676 47.4927 54.2304L46.924 53.4676C48.0664 52.7382 48.8101 51.5491 49.1548 49.9028H47.2071V49.0039H47.2096Z" fill="var(--fill-0, #FF6902)"/>
|
||||
<path id="Vector_4" d="M63.6535 46.8953C64.8808 48.1589 66.2908 49.1528 67.8809 49.8745L67.4203 50.7041C66.9186 50.4627 66.4606 50.2135 66.0489 49.9516V50.8299H63.7873V52.2965H66.5378V53.1954H63.7873V54.739H67.4281V55.6481H59.215V54.739H62.8455V53.1954H60.0847V52.2965H62.8455V50.8299H60.5839V49.9516C60.167 50.2058 59.6962 50.4627 59.1738 50.7246L58.7236 49.913C60.4269 49.0989 61.8446 48.0921 62.9819 46.8953H63.6535ZM66.0309 49.9413C65.012 49.3172 64.1089 48.5801 63.319 47.7325C62.5882 48.5339 61.6851 49.271 60.607 49.9413H66.0309Z" fill="var(--fill-0, #FF6902)"/>
|
||||
<path id="Vector_5" d="M73.6859 50.4319H74.7229V48.3618H73.5779V47.4911H76.7401V48.3618H75.6646V50.4319H76.5368V51.3102H75.6646V53.031C76.0505 52.8615 76.4082 52.6946 76.7401 52.5328V53.4317C75.8061 53.894 74.7769 54.2972 73.6473 54.6439L73.4132 53.7245C73.9355 53.6063 74.3729 53.4933 74.7254 53.3829V51.3128H73.6885V50.4319H73.6859ZM76.8276 48.5159H78.9812V46.9235H79.8715V48.5159H81.2017C80.9341 48.2102 80.5893 47.8815 80.1648 47.5296L80.6922 47.0211C81.2017 47.4064 81.616 47.7762 81.935 48.1358L81.5645 48.5159H82.1126V49.4045H79.8715V50.2752C80.0027 50.6861 80.1519 51.0688 80.3217 51.4284C80.7077 50.9789 81.0628 50.4832 81.3895 49.9439L82.0842 50.4627C81.634 51.1664 81.1811 51.7494 80.7231 52.2117C81.2069 53.0464 81.7986 53.7758 82.5036 54.3999L81.8861 55.1319C81.037 54.2972 80.3655 53.3212 79.8689 52.2014V54.9085C79.8689 55.5274 79.5498 55.8356 78.9092 55.8356H77.8851L77.6895 54.9573C78.0549 55.0035 78.3585 55.0266 78.6004 55.0266C78.8551 55.0266 78.9812 54.9136 78.9812 54.685V52.6714C78.3817 53.5113 77.687 54.2381 76.8971 54.8494L76.4082 54.0481C77.3679 53.4163 78.2247 52.543 78.9812 51.4309V49.4097H76.8276V48.5159ZM77.512 50.0209C77.9546 50.6733 78.2942 51.228 78.5309 51.6929L77.8851 52.1424C77.6098 51.6338 77.2496 51.0765 76.7993 50.4729L77.512 50.0209Z" fill="var(--fill-0, #FF6902)"/>
|
||||
</g>
|
||||
<path id="Vector_6" d="M11.1801 50.889H0.165039V51.4386H11.1801V50.889Z" fill="var(--fill-0, #FF6902)"/>
|
||||
<path id="Vector_7" d="M97 50.889H85.7508V51.5671H97V50.889Z" fill="var(--fill-0, #FF6902)"/>
|
||||
<g id="Group_2">
|
||||
<path id="Vector_8" d="M64.2864 27.2064C55.1033 35.3686 44.6466 38.6072 40.9337 34.4414C39.4748 32.8054 39.2741 30.273 40.1207 27.304C37.5091 32.1016 36.9481 36.4293 39.0863 38.8281C42.8017 42.994 53.2585 39.7527 62.439 31.5931C68.0173 26.6362 71.8408 21.0039 73.1504 16.4117C71.2232 19.9508 68.1845 23.7443 64.2864 27.2064Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_9" d="M3.07218 12.536H0.810499C0.362795 12.536 0 12.8982 0 13.3451V15.6026C0 16.0495 0.362795 16.4117 0.810499 16.4117H3.07218C3.51988 16.4117 3.88268 16.0495 3.88268 15.6026V13.3451C3.88268 12.8982 3.51988 12.536 3.07218 12.536Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_10" d="M3.07218 17.6804H0.810499C0.362795 17.6804 0 18.0451 0 18.492V30.1702C0 30.6171 0.362795 30.9793 0.810499 30.9793H3.07218C3.51988 30.9793 3.88268 30.6171 3.88268 30.1702V18.492C3.88268 18.0451 3.51988 17.6804 3.07218 17.6804Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_11" d="M11.6889 17.6907C10.9711 17.701 10.2841 17.8397 9.64853 18.0811C9.50701 17.8422 9.24714 17.6804 8.94867 17.6804H6.5146C6.0669 17.6804 5.7041 18.0426 5.7041 18.4895V23.847V23.9806V30.2113C5.7041 30.6582 6.0669 31.0204 6.5146 31.0204H8.94867C9.39637 31.0204 9.75917 30.6582 9.75917 30.2113V23.9831V23.7571C9.75917 22.6193 10.7086 21.6973 11.8587 21.741C12.9523 21.7821 13.8039 22.7144 13.8039 23.8085V30.2447C13.8039 30.6916 14.1667 31.0538 14.6144 31.0538H17.0485C17.4962 31.0538 17.859 30.6916 17.859 30.2447V23.7571C17.8616 20.3797 15.0853 17.6393 11.6889 17.6907Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_12" d="M90.8296 17.6907C90.1606 17.701 89.5199 17.8217 88.9204 18.0349V10.6303C88.9204 10.1835 88.5576 9.82132 88.1099 9.82132H85.6758C85.2281 9.82132 84.8653 10.1835 84.8653 10.6303V22.907C84.8653 22.9969 84.873 23.0842 84.8833 23.169C84.8576 23.3924 84.8447 23.6184 84.8447 23.847V30.2113C84.8447 30.6582 85.2075 31.0204 85.6552 31.0204H88.0893C88.537 31.0204 88.8998 30.6582 88.8998 30.2113V23.7571C88.8998 22.6193 89.8492 21.6973 90.9994 21.741C92.0929 21.7821 92.9446 22.7144 92.9446 23.8085V30.2447C92.9446 30.6916 93.3074 31.0538 93.7551 31.0538H96.1891C96.6368 31.0538 96.9996 30.6916 96.9996 30.2447V23.7571C96.9996 20.3797 94.2234 17.6393 90.8296 17.6907Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_13" d="M31.0412 17.7909H28.6072C28.1595 17.7909 27.7967 18.153 27.7967 18.5999V19.4089C27.7967 20.4748 26.9656 21.3506 25.9184 21.4276C25.8386 21.4251 25.7563 21.4251 25.6765 21.4251C25.6559 21.4251 25.6379 21.4276 25.6173 21.4276C25.0898 21.3891 24.5238 21.1477 23.9886 20.6314C23.8316 20.4799 23.7416 20.2693 23.7416 20.051V10.6303C23.7416 10.1835 23.3788 9.82132 22.9311 9.82132H20.497C20.0493 9.82132 19.6865 10.1835 19.6865 10.6303V18.5999V21.985V27.5865V30.3269C19.6865 30.7738 20.0493 31.1359 20.497 31.1359H22.9311C23.3788 31.1359 23.7416 30.7738 23.7416 30.3269V30.2653V27.494C23.7416 26.4307 24.5701 25.5549 25.6147 25.4779C25.7125 25.4805 25.8103 25.4805 25.9081 25.4779C26.9759 25.5524 27.7967 26.4693 27.7967 27.5454V30.3295C27.7967 30.7764 28.1595 31.1385 28.6072 31.1385H31.0412C31.4889 31.1385 31.8517 30.7764 31.8517 30.3295V27.4966C31.8517 25.9453 31.2651 24.5302 30.3028 23.454C31.2651 22.3805 31.8517 20.9628 31.8517 19.4089V18.5999C31.8517 18.153 31.4889 17.7909 31.0412 17.7909Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_14" d="M39.8324 21.7744C39.8761 21.7769 39.9173 21.7821 39.9585 21.7846C40.7355 20.6546 41.6052 19.5271 42.5598 18.4124C41.6927 17.9604 40.7046 17.7087 39.66 17.7267C38.9807 17.7369 38.3323 17.8628 37.7277 18.0785C37.6633 17.8628 37.4678 17.7061 37.2311 17.7061H34.5062C34.0585 17.7061 33.6957 18.0682 33.6957 18.5151V23.4181C33.6855 23.5722 33.6777 23.7263 33.6777 23.883V30.2473C33.6777 30.4759 33.7729 30.6839 33.9273 30.8303C34.074 30.9818 34.2798 31.0769 34.5088 31.0769H36.9429C37.3906 31.0769 37.7534 30.7147 37.7534 30.2678V23.5285C37.8846 22.514 38.7723 21.7358 39.8324 21.7744Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_15" d="M41.5516 25.4805C41.7291 26.5746 42.1948 27.6199 42.8844 28.4854H42.8818C45.3493 31.6239 50.2304 31.891 53.4003 29.1943C53.5701 29.0504 53.5881 28.7936 53.444 28.6241L51.5709 26.4256C51.432 26.2612 51.1875 26.2381 51.0151 26.3665C49.6257 27.4016 48.1925 27.643 46.7362 26.9008L51.3316 25.0079L54.6611 23.6338C54.8695 23.5491 54.9673 23.3102 54.8798 23.1048C54.5299 22.2675 54.0847 21.1246 53.6087 20.5056C52.3685 18.7617 50.3461 17.6907 48.1488 17.6933H48.1514C44.0628 17.6624 40.8466 21.4662 41.5516 25.4805ZM45.3262 23.9215C45.4909 21.7384 48.262 20.5698 49.9164 22.0312C48.738 22.5166 46.5021 23.4386 45.3262 23.9241V23.9215Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_16" d="M77.6686 21.6125C78.5975 21.2299 79.6396 21.3352 80.4604 21.8668C80.7768 22.0723 81.1988 22.0209 81.4664 21.7538L82.9433 20.2796C83.2932 19.9303 83.2495 19.355 82.8533 19.0571C81.7006 18.1864 80.2854 17.7087 78.8213 17.7112C75.7929 17.7112 73.1401 19.7428 72.3579 22.663C71.5732 25.5832 72.852 28.6652 75.4764 30.1779C77.8256 31.5315 80.7305 31.3234 82.8507 29.7285C83.2469 29.4306 83.2932 28.8553 82.9433 28.5034L81.4664 27.0292C81.1988 26.7621 80.7794 26.7107 80.4604 26.9162C79.6396 27.4478 78.5975 27.5531 77.6686 27.1704C76.5417 26.7056 75.8084 25.6089 75.8084 24.3915C75.8084 23.1767 76.5417 22.0774 77.6686 21.6125Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_17" d="M69.361 19.617V18.1299C69.361 17.9064 69.1783 17.7241 68.9545 17.7241H65.9132C65.6893 17.7241 65.5067 17.9064 65.5067 18.1299V18.3225C64.5907 17.8936 63.564 17.665 62.4808 17.6933C58.9481 17.7909 56.0663 20.67 55.9788 24.1989C55.9145 26.7107 57.2421 28.9169 59.2465 30.1086C60.2757 29.3278 61.2921 28.488 62.2904 27.5942C62.4345 27.4632 62.5786 27.3322 62.7227 27.2012C62.7047 27.2012 62.6892 27.2038 62.6712 27.2038C60.9987 27.2038 59.6582 25.7527 59.8512 24.0448C59.9953 22.7452 61.0451 21.6973 62.347 21.5535C64.0581 21.3634 65.5118 22.699 65.5118 24.3684C65.5118 24.3889 65.5118 24.4095 65.5092 24.4326C66.9681 22.8556 68.2649 21.235 69.361 19.617Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_18" d="M65.5089 30.3166V30.9536H68.9567C69.1806 30.9536 69.3633 30.7712 69.3633 30.5478V26.102C68.0356 27.6173 67.0836 28.9066 65.5089 30.3166Z" fill="var(--fill-0, #FF6800)"/>
|
||||
<path id="Vector_19" d="M48.9692 12.2458C57.8229 3.65217 68.4906 0.272244 72.7979 4.69492C74.6762 6.62374 75.0338 9.71602 74.1101 13.304C76.2791 8.46524 76.467 4.15814 74.159 1.78756C70.037 -2.44249 59.5185 1.09411 50.6674 9.6852C47.765 12.5027 45.4004 15.5153 43.6816 18.4381C45.1431 16.3372 46.9185 14.2389 48.9692 12.2458Z" fill="var(--fill-0, #FF6800)"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_0_30">
|
||||
<rect width="97" height="56" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 12 KiB |
@@ -4,7 +4,7 @@ import type {
|
||||
CreateGoodRequest,
|
||||
UpdateGoodRequest,
|
||||
BatchCreateGoodsRequest,
|
||||
UpdatePriorityRequest,
|
||||
BatchPriorityRequest,
|
||||
GoodsFilter,
|
||||
PaginatedResult,
|
||||
} from '@/types'
|
||||
@@ -40,8 +40,8 @@ export const goodsApi = {
|
||||
return request.post<any, Good[]>('/goods/batch', data)
|
||||
},
|
||||
|
||||
// Update priority
|
||||
updatePriority: (data: UpdatePriorityRequest) => {
|
||||
return request.patch<any, Good[]>('/goods/priority', data)
|
||||
// Batch update priority
|
||||
batchUpdatePriority: (data: BatchPriorityRequest) => {
|
||||
return request.patch<any, { count: number }>('/goods/batch-priority', data)
|
||||
},
|
||||
}
|
||||
@@ -3,7 +3,11 @@ import type { SyncLog } from '@/types'
|
||||
|
||||
export const syncApi = {
|
||||
syncProducts: () => {
|
||||
return request.post<any, SyncLog>('/sync/products')
|
||||
return request.post<any, { message: string }>('/sync/products')
|
||||
},
|
||||
|
||||
syncCategories: () => {
|
||||
return request.post<any, { message: string }>('/sync/categories')
|
||||
},
|
||||
|
||||
getSyncStatus: (limit?: number) => {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import request from './request'
|
||||
|
||||
export interface UploadResult {
|
||||
url: string
|
||||
filename: string
|
||||
}
|
||||
|
||||
export const uploadApi = {
|
||||
uploadImage: (file: File) => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return request.post<any, UploadResult>('/upload/image', formData)
|
||||
},
|
||||
}
|
||||
Vendored
+4
-4
@@ -15,7 +15,6 @@ declare module 'vue' {
|
||||
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
|
||||
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElCard: typeof import('element-plus/es')['ElCard']
|
||||
ElCascader: typeof import('element-plus/es')['ElCascader']
|
||||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
|
||||
@@ -30,23 +29,24 @@ declare module 'vue' {
|
||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||
ElImage: typeof import('element-plus/es')['ElImage']
|
||||
ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
|
||||
ElInput: typeof import('element-plus/es')['ElInput']
|
||||
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
|
||||
ElMain: typeof import('element-plus/es')['ElMain']
|
||||
ElMenu: typeof import('element-plus/es')['ElMenu']
|
||||
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
||||
ElOption: typeof import('element-plus/es')['ElOption']
|
||||
ElOptionGroup: typeof import('element-plus/es')['ElOptionGroup']
|
||||
ElPopover: typeof import('element-plus/es')['ElPopover']
|
||||
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
|
||||
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
ElTabPane: typeof import('element-plus/es')['ElTabPane']
|
||||
ElTabs: typeof import('element-plus/es')['ElTabs']
|
||||
ElTag: typeof import('element-plus/es')['ElTag']
|
||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||
ElTree: typeof import('element-plus/es')['ElTree']
|
||||
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||
ImageUpload: typeof import('./components/ImageUpload.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Plus, Loading } from '@element-plus/icons-vue'
|
||||
import type { UploadProps } from 'element-plus'
|
||||
import { uploadApi } from '@/api/upload'
|
||||
|
||||
const model = defineModel<string>({ default: '' })
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
width?: number
|
||||
height?: number
|
||||
shape?: 'square' | 'circle'
|
||||
label?: string
|
||||
}>(), {
|
||||
width: 80,
|
||||
height: 80,
|
||||
shape: 'square',
|
||||
label: '点击上传',
|
||||
})
|
||||
|
||||
const uploading = ref(false)
|
||||
const previewVisible = ref(false)
|
||||
|
||||
const customUpload: UploadProps['httpRequest'] = async (options) => {
|
||||
const file = options.file as File
|
||||
uploading.value = true
|
||||
try {
|
||||
const result = await uploadApi.uploadImage(file)
|
||||
model.value = result.url
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || '上传失败')
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function removeImage() {
|
||||
model.value = ''
|
||||
}
|
||||
|
||||
function onImgError() {
|
||||
console.warn('Image failed to load:', model.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="img-upload">
|
||||
<el-upload
|
||||
class="img-uploader"
|
||||
:show-file-list="false"
|
||||
:http-request="customUpload"
|
||||
accept="image/*"
|
||||
>
|
||||
<div v-if="model" class="img-preview-wrap" :style="{ width: width + 'px', height: height + 'px', borderRadius: shape === 'circle' ? '50%' : '8px' }">
|
||||
<img :src="model" class="img-preview-img" @click.stop="previewVisible = true" @error="onImgError" />
|
||||
<div class="img-overlay">
|
||||
<span @click.stop="previewVisible = true">预览</span>
|
||||
<span @click.stop="removeImage">删除</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="img-placeholder" :style="{ width: width + 'px', height: height + 'px', borderRadius: shape === 'circle' ? '50%' : '8px' }">
|
||||
<el-icon v-if="!uploading" :size="20"><Plus /></el-icon>
|
||||
<el-icon v-else :size="20" class="is-loading"><Loading /></el-icon>
|
||||
<span class="img-placeholder-text">{{ uploading ? '上传中' : label }}</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
|
||||
<el-image-viewer v-if="previewVisible" :url-list="[model]" @close="previewVisible = false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.img-upload {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.img-uploader {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.img-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
border: 1px dashed #d9d9d9;
|
||||
background: #fafafa;
|
||||
color: #a8abb2;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.img-placeholder:hover {
|
||||
border-color: var(--brand-color, #ff6800);
|
||||
color: var(--brand-color, #ff6800);
|
||||
}
|
||||
|
||||
.img-placeholder-text {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.img-preview-wrap {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.img-preview-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.img-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.img-preview-wrap:hover .img-overlay {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.img-overlay span {
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.img-overlay span:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.is-loading {
|
||||
animation: rotating 1.5s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes rotating {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
@@ -71,11 +71,8 @@ function handleCommand(command: string) {
|
||||
<!-- Sidebar -->
|
||||
<el-aside :width="collapsed ? '64px' : '240px'" class="layout-aside">
|
||||
<div class="brand" :class="{ collapsed }">
|
||||
<div class="brand-mark">IR</div>
|
||||
<div v-if="!collapsed" class="brand-text">
|
||||
<div class="brand-name">Inkreach</div>
|
||||
<div class="brand-tag">官网后台</div>
|
||||
</div>
|
||||
<img src="/logo-unified.svg" class="brand-logo" alt="InkReach" />
|
||||
<span v-if="!collapsed" class="brand-text">印美达官网后台</span>
|
||||
</div>
|
||||
|
||||
<el-menu
|
||||
@@ -162,9 +159,9 @@ function handleCommand(command: string) {
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 8px;
|
||||
height: 56px;
|
||||
padding: 0 16px;
|
||||
padding: 0 20px;
|
||||
border-bottom: 1px solid #2b2b33;
|
||||
background: #16161a;
|
||||
overflow: hidden;
|
||||
@@ -175,37 +172,18 @@ function handleCommand(command: string) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
flex: 0 0 auto;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
background: var(--brand-color);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.5px;
|
||||
.brand-logo {
|
||||
height: 24px;
|
||||
width: auto;
|
||||
object-fit: contain;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.brand-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.brand-name {
|
||||
color: #fff;
|
||||
color: #e4e4e7;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.brand-tag {
|
||||
color: #9ca3af;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.layout-aside :deep(.el-menu) {
|
||||
|
||||
@@ -85,6 +85,15 @@ export interface UpdatePriorityRequest {
|
||||
priority: number
|
||||
}
|
||||
|
||||
export interface BatchPriorityItem {
|
||||
id: number
|
||||
priority: number
|
||||
}
|
||||
|
||||
export interface BatchPriorityRequest {
|
||||
items: BatchPriorityItem[]
|
||||
}
|
||||
|
||||
// Country types
|
||||
export interface Country {
|
||||
id: string
|
||||
@@ -234,6 +243,7 @@ export interface OriginGood {
|
||||
goodPrice: string | null
|
||||
sdsGoodId: string
|
||||
sdsCategoryId: string | null
|
||||
delisted?: boolean
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
@@ -245,6 +255,7 @@ export interface OriginGoodsTreeNode {
|
||||
goodImage: string | null
|
||||
goodPrice: string | null
|
||||
sdsGoodId: string
|
||||
delisted: boolean
|
||||
configuredCount: number
|
||||
configuredCountries: string[]
|
||||
configuredTags: { tagName: string; tagColor: string | null; tagFontColor: string | null; tagGroupId: string | null; tagGroupName: string | null; sortOrder: number }[]
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
||||
import { useVirtualList } from '@vueuse/core'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
Plus, Edit, Delete, Search,
|
||||
FolderAdd, Aim,
|
||||
Plus, Edit, Delete, Search, Top,
|
||||
FolderAdd, Aim, ArrowDown,
|
||||
} from '@element-plus/icons-vue'
|
||||
import type {
|
||||
CategoryTree, Country, Tag, TagGroup, Good, Position,
|
||||
@@ -17,7 +18,7 @@ import { tagGroupsApi } from '@/api/tag-groups'
|
||||
import { positionsApi } from '@/api/positions'
|
||||
import { originGoodsApi } from '@/api/origin-goods'
|
||||
|
||||
const mode = ref<'category' | 'country'>('category')
|
||||
const mode = ref<'category' | 'country' | 'global'>('category')
|
||||
const loading = ref(false)
|
||||
|
||||
const leftTreeRef = ref()
|
||||
@@ -32,12 +33,26 @@ const allGoods = ref<Good[]>([])
|
||||
const searchKeyword = ref('')
|
||||
const selectedCountryIds = ref<string[]>([])
|
||||
const selectedTagIds = ref<string[]>([])
|
||||
const sortBy = ref(localStorage.getItem('goods-sort-by') || 'default')
|
||||
|
||||
const SORT_OPTIONS = [
|
||||
{ label: '默认排序', value: 'default' },
|
||||
{ label: '优先级 高→低', value: 'priority-desc' },
|
||||
{ label: '优先级 低→高', value: 'priority-asc' },
|
||||
{ label: '名称 A→Z', value: 'name-asc' },
|
||||
{ label: '名称 Z→A', value: 'name-desc' },
|
||||
{ label: '最新创建', value: 'created-desc' },
|
||||
{ label: '最早创建', value: 'created-asc' },
|
||||
]
|
||||
|
||||
watch(sortBy, (val) => localStorage.setItem('goods-sort-by', val))
|
||||
|
||||
const treeProps = { label: 'label', children: 'children' }
|
||||
|
||||
const leftPct = ref(55)
|
||||
const showAllLeft = ref(false)
|
||||
const showAllRight = ref(false)
|
||||
const showUnconfiguredOnly = ref(false)
|
||||
|
||||
function onSplitterMouseDown(e: MouseEvent) {
|
||||
e.preventDefault()
|
||||
@@ -62,16 +77,21 @@ function onSplitterMouseDown(e: MouseEvent) {
|
||||
|
||||
function setExpand(treeRef: any, data: any[], expand: boolean) {
|
||||
nextTick(() => {
|
||||
if (!treeRef.value) return
|
||||
if (expand) {
|
||||
const keys: string[] = []
|
||||
function collect(arr: any[]) {
|
||||
for (const n of arr) { keys.push(n.id); if (n.children) collect(n.children) }
|
||||
const tree = treeRef?.value ?? treeRef
|
||||
if (!tree?.getNode) return
|
||||
const keys: string[] = []
|
||||
function collect(arr: any[]) {
|
||||
for (const n of arr) {
|
||||
keys.push(n.id)
|
||||
if (n.children?.length) collect(n.children)
|
||||
}
|
||||
}
|
||||
collect(data)
|
||||
for (const key of keys) {
|
||||
const node = tree.getNode(key)
|
||||
if (node && node.childNodes?.length) {
|
||||
node.expanded = expand
|
||||
}
|
||||
collect(data)
|
||||
treeRef.value.setExpandedKeys(keys)
|
||||
} else {
|
||||
treeRef.value.setExpandedKeys([])
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -106,6 +126,31 @@ async function loadAll() {
|
||||
finally { loading.value = false }
|
||||
}
|
||||
|
||||
// Set of origin good IDs currently visible in the right tree (active/non-delisted)
|
||||
const activeOriginGoodIds = computed(() => {
|
||||
const ids = new Set<string>()
|
||||
function traverse(nodes: any[]) {
|
||||
for (const n of nodes) {
|
||||
if (n.isOG && n.rawId) ids.add(String(n.rawId))
|
||||
if (n.children?.length) traverse(n.children)
|
||||
}
|
||||
}
|
||||
traverse(rightTreeData.value)
|
||||
return ids
|
||||
})
|
||||
|
||||
// Sort tags by their group's sortOrder, then by tag's sortOrder within group
|
||||
function sortTagsByGroup(tags: Tag[]): Tag[] {
|
||||
const groupOrder = new Map<string, number>()
|
||||
allTagGroups.value.forEach((g, i) => groupOrder.set(g.id, i))
|
||||
return [...tags].sort((a, b) => {
|
||||
const ga = a.tagGroupId ? (groupOrder.get(a.tagGroupId) ?? 999) : 999
|
||||
const gb = b.tagGroupId ? (groupOrder.get(b.tagGroupId) ?? 999) : 999
|
||||
if (ga !== gb) return ga - gb
|
||||
return (a.sortOrder ?? 0) - (b.sortOrder ?? 0)
|
||||
})
|
||||
}
|
||||
|
||||
function goodToNode(g: Good): any {
|
||||
return {
|
||||
id: 'good-' + g.id,
|
||||
@@ -116,17 +161,18 @@ function goodToNode(g: Good): any {
|
||||
goodName: g.goodName,
|
||||
goodImage: g.goodImage || g.originGood?.goodImage || null,
|
||||
country: g.country?.countryName || g.countryId,
|
||||
tags: g.tags || [],
|
||||
tags: sortTagsByGroup(g.tags || []),
|
||||
priority: g.goodPriority,
|
||||
originGoodId: g.originGoodId,
|
||||
originGoodName: g.originGood?.goodName || null,
|
||||
originGoodImage: g.originGood?.goodImage || null,
|
||||
originGoodPrice: g.originGood?.goodPrice || null,
|
||||
sdsGoodId: g.originGood?.sdsGoodId || null,
|
||||
originDelisted: !!g.originGoodId && !activeOriginGoodIds.value.has(String(g.originGoodId)),
|
||||
}
|
||||
}
|
||||
|
||||
// Computed: goods after applying search + country + tag filters
|
||||
// Computed: goods after applying search + country + tag filters + sort
|
||||
const filteredGoods = computed(() => {
|
||||
let result = allGoods.value
|
||||
if (searchKeyword.value) {
|
||||
@@ -141,7 +187,28 @@ const filteredGoods = computed(() => {
|
||||
return selectedTagIds.value.some(id => ids.includes(id))
|
||||
})
|
||||
}
|
||||
return result
|
||||
const sorted = [...result]
|
||||
switch (sortBy.value) {
|
||||
case 'priority-desc':
|
||||
sorted.sort((a, b) => (b.goodPriority || 0) - (a.goodPriority || 0) || new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
|
||||
break
|
||||
case 'priority-asc':
|
||||
sorted.sort((a, b) => (a.goodPriority || 0) - (b.goodPriority || 0) || new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
|
||||
break
|
||||
case 'name-asc':
|
||||
sorted.sort((a, b) => (a.goodName || '').localeCompare(b.goodName || '', 'zh-Hans-CN'))
|
||||
break
|
||||
case 'name-desc':
|
||||
sorted.sort((a, b) => (b.goodName || '').localeCompare(a.goodName || '', 'zh-Hans-CN'))
|
||||
break
|
||||
case 'created-desc':
|
||||
sorted.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
|
||||
break
|
||||
case 'created-asc':
|
||||
sorted.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime())
|
||||
break
|
||||
}
|
||||
return sorted
|
||||
})
|
||||
|
||||
function mapCatNodes(nodes: CategoryTree[], goods: Good[]): any[] {
|
||||
@@ -195,22 +262,37 @@ function buildRightTree(tree: OriginGoodsTreeResponse) {
|
||||
goodImage: og.goodImage,
|
||||
goodPrice: og.goodPrice,
|
||||
sdsGoodId: og.sdsGoodId,
|
||||
configuredCount: og.configuredCount ?? 0,
|
||||
configuredCountries: og.configuredCountries ?? [],
|
||||
}))
|
||||
return {
|
||||
id: 'rc-' + node.categoryId,
|
||||
label: node.categoryName,
|
||||
configuredCount: node.configuredCount ?? 0,
|
||||
totalCount: node.totalCount ?? 0,
|
||||
children: [...children, ...goods],
|
||||
}
|
||||
}
|
||||
rightTreeData.value = tree.tree.map(mapCat)
|
||||
}
|
||||
|
||||
function rightFilterNode(value: string, data: any) {
|
||||
if (!value) return true
|
||||
if (data.isOG) return data.label.includes(value)
|
||||
function rightFilterNode(_value: string, data: any) {
|
||||
if (data.isOG) {
|
||||
if (showUnconfiguredOnly.value && data.configuredCount > 0) return false
|
||||
if (searchKeyword.value && !data.label.includes(searchKeyword.value)) return false
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function toggleUnconfiguredFilter() {
|
||||
showUnconfiguredOnly.value = !showUnconfiguredOnly.value
|
||||
rightTreeRef.value?.filter?.('')
|
||||
if (showUnconfiguredOnly.value) {
|
||||
nextTick(() => setExpand(rightTreeRef.value, rightTreeData.value, true))
|
||||
}
|
||||
}
|
||||
|
||||
// Right tree search filter
|
||||
watch(searchKeyword, () => {
|
||||
rightTreeRef.value?.filter?.('')
|
||||
@@ -273,24 +355,36 @@ const configOG = ref<any>(null)
|
||||
const configDropTarget = ref<any>(null)
|
||||
const configForm = ref({
|
||||
countryId: '', cascaderCategory: [] as string[], categoryId: '',
|
||||
tagIds: [] as string[], positionId: '', priority: 0, goodImage: '',
|
||||
tagIds: [] as string[], positionId: '', goodImage: '',
|
||||
})
|
||||
const configPositions = ref<Position[]>([])
|
||||
|
||||
function openConfigModal(og: any, dropTarget: any) {
|
||||
configOG.value = og
|
||||
configDropTarget.value = dropTarget
|
||||
configForm.value = { countryId: '', cascaderCategory: [], categoryId: '', tagIds: [], positionId: '', priority: 0, goodImage: og.goodImage || '' }
|
||||
if (mode.value === 'category') {
|
||||
configForm.value.categoryId = dropTarget.id
|
||||
configForm.value.cascaderCategory = findCategoryPath(allCategories.value, dropTarget.id)
|
||||
} else {
|
||||
configForm.value.countryId = dropTarget.id
|
||||
configForm.value = { countryId: '', cascaderCategory: [], categoryId: '', tagIds: [], positionId: '', goodImage: og.goodImage || '' }
|
||||
if (dropTarget) {
|
||||
if (mode.value === 'category') {
|
||||
configForm.value.categoryId = dropTarget.id
|
||||
configForm.value.cascaderCategory = findCategoryPath(allCategories.value, dropTarget.id)
|
||||
} else {
|
||||
configForm.value.countryId = dropTarget.id
|
||||
}
|
||||
}
|
||||
loadConfigPositions()
|
||||
configVisible.value = true
|
||||
}
|
||||
|
||||
function openConfigFromRightTree(data: any) {
|
||||
openConfigModal({
|
||||
rawId: data.rawId,
|
||||
goodName: data.goodName,
|
||||
goodImage: data.goodImage,
|
||||
goodPrice: data.goodPrice,
|
||||
sdsGoodId: data.sdsGoodId,
|
||||
}, null)
|
||||
}
|
||||
|
||||
async function loadConfigPositions() {
|
||||
const params: any = { page: 1, pageSize: 200 }
|
||||
if (configForm.value.countryId) params.countryId = configForm.value.countryId
|
||||
@@ -319,11 +413,11 @@ async function handleConfigSubmit() {
|
||||
categoryId: Number(configForm.value.categoryId),
|
||||
tagIds: configForm.value.tagIds.map(Number),
|
||||
positionId: configForm.value.positionId ? Number(configForm.value.positionId) : undefined,
|
||||
goodPriority: configForm.value.priority,
|
||||
} as any)
|
||||
ElMessage.success('配置成功')
|
||||
configVisible.value = false
|
||||
refreshLeftTree()
|
||||
refreshRightTree()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || '配置失败')
|
||||
} finally { configLoading.value = false }
|
||||
@@ -335,7 +429,7 @@ const editLoading = ref(false)
|
||||
const editGood = ref<Good | null>(null)
|
||||
const editForm = ref({
|
||||
id: '', goodName: '', goodImage: '', countryId: '', cascaderCategory: [] as string[],
|
||||
categoryId: '', tagIds: [] as string[], positionId: '', priority: 0,
|
||||
categoryId: '', tagIds: [] as string[], positionId: '',
|
||||
})
|
||||
|
||||
function openEdit(g: Good) {
|
||||
@@ -347,7 +441,7 @@ function openEdit(g: Good) {
|
||||
cascaderCategory: findCategoryPath(allCategories.value, g.categoryId),
|
||||
categoryId: g.categoryId,
|
||||
tagIds: (g.tags || []).map(t => t.id),
|
||||
positionId: g.positionId || '', priority: g.goodPriority,
|
||||
positionId: g.positionId || '',
|
||||
}
|
||||
editVisible.value = true
|
||||
}
|
||||
@@ -362,11 +456,11 @@ async function handleEditSubmit() {
|
||||
categoryId: Number(editForm.value.categoryId),
|
||||
tagIds: editForm.value.tagIds.map(Number),
|
||||
positionId: editForm.value.positionId ? Number(editForm.value.positionId) : null,
|
||||
goodPriority: editForm.value.priority,
|
||||
} as any)
|
||||
ElMessage.success('更新成功')
|
||||
editVisible.value = false
|
||||
refreshLeftTree()
|
||||
refreshRightTree()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || '更新失败')
|
||||
} finally { editLoading.value = false }
|
||||
@@ -386,6 +480,7 @@ async function handleDeleteGood(g: Good) {
|
||||
ElMessage.success('删除成功')
|
||||
editVisible.value = false
|
||||
refreshLeftTree()
|
||||
refreshRightTree()
|
||||
}
|
||||
|
||||
// ─── Right tree locate ───
|
||||
@@ -424,6 +519,41 @@ function locateInRightTree(originGoodId: string) {
|
||||
}, 250)
|
||||
}
|
||||
|
||||
function locateInLeftTree(originGoodId: string) {
|
||||
const good = allGoods.value.find(g => g.originGoodId === originGoodId)
|
||||
if (!good) {
|
||||
ElMessage.warning('该原产品尚未配置到官网')
|
||||
return
|
||||
}
|
||||
const targetKey = 'good-' + good.id
|
||||
const tree = leftTreeRef.value
|
||||
if (!tree?.getNode) return
|
||||
// Build the category path to expand
|
||||
const catPath: string[] = []
|
||||
function findCatPath(nodes: CategoryTree[], targetCatId: string): boolean {
|
||||
for (const n of nodes) {
|
||||
if (n.id === targetCatId) { catPath.push(n.id); return true }
|
||||
if (n.children?.length && findCatPath(n.children, targetCatId)) {
|
||||
catPath.unshift(n.id); return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
findCatPath(allCategories.value, good.categoryId)
|
||||
// Expand ancestors
|
||||
for (const keyId of catPath) {
|
||||
const node = tree.getNode(keyId)
|
||||
if (node) node.expanded = true
|
||||
}
|
||||
setTimeout(() => {
|
||||
tree.setCurrentKey(targetKey)
|
||||
nextTick(() => {
|
||||
const el = document.querySelector('.gv-left .el-tree-node.is-current') as HTMLElement
|
||||
el?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
})
|
||||
}, 250)
|
||||
}
|
||||
|
||||
// ─── Left Tree: Category CRUD ───
|
||||
const catEditVisible = ref(false)
|
||||
const catEditMode = ref<'create' | 'edit'>('create')
|
||||
@@ -732,6 +862,26 @@ const tagTreeData = computed<TreeNode[]>(() => {
|
||||
return groupNodes
|
||||
})
|
||||
|
||||
const groupedTagOptions = computed(() => {
|
||||
const groups = allTagGroups.value
|
||||
.slice()
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder)
|
||||
.map((g) => ({
|
||||
id: g.id,
|
||||
label: g.groupName,
|
||||
tags: allTags.value
|
||||
.filter((t) => t.tagGroupId === g.id)
|
||||
.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0)),
|
||||
}))
|
||||
const ungrouped = allTags.value
|
||||
.filter((t) => !t.tagGroupId)
|
||||
.sort((a, b) => a.tagName.localeCompare(b.tagName))
|
||||
if (ungrouped.length > 0) {
|
||||
groups.push({ id: 'ungrouped', label: '未分组', tags: ungrouped })
|
||||
}
|
||||
return groups
|
||||
})
|
||||
|
||||
function toggleTagInSelection(tagId: string): void {
|
||||
const idx = selectedTagIds.value.indexOf(tagId)
|
||||
if (idx >= 0) selectedTagIds.value.splice(idx, 1)
|
||||
@@ -799,8 +949,150 @@ async function quickCreateTag(targetForm: () => void) {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
async function quickCreateTagGroup() {
|
||||
try {
|
||||
const { value } = await ElMessageBox.prompt('请输入分组名称', '新建分组', {
|
||||
confirmButtonText: '新建', cancelButtonText: '取消', inputPlaceholder: '分组名称',
|
||||
})
|
||||
if (!value.trim()) return
|
||||
const maxSort = Math.max(0, ...allTagGroups.value.map(g => g.sortOrder))
|
||||
await tagGroupsApi.createTagGroup({ groupName: value.trim(), sortOrder: maxSort + 1 } as any)
|
||||
await reloadTags()
|
||||
ElMessage.success('已创建分组')
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function onModeChange() {}
|
||||
|
||||
// ─── Global mode: flat list with move-to-top ───
|
||||
const globalGoodsNodes = computed(() =>
|
||||
filteredGoods.value.map(g => goodToNode(g))
|
||||
)
|
||||
|
||||
const { list: virtualList, containerProps: virtualContainer, wrapperProps: virtualWrapper } = useVirtualList(
|
||||
globalGoodsNodes,
|
||||
{ itemHeight: 64, overscan: 5 },
|
||||
)
|
||||
|
||||
const moveTopLoading = ref<string | null>(null)
|
||||
const globalSelectedIds = ref<Set<string>>(new Set())
|
||||
|
||||
// ─── Drag-to-reorder in global mode ───
|
||||
const dragGoodId = ref<string | null>(null)
|
||||
const dragOverGoodId = ref<string | null>(null)
|
||||
const dragOverPos = ref<'before' | 'after'>('before')
|
||||
|
||||
function onGlobalDragStart(_e: DragEvent, goodId: string) {
|
||||
dragGoodId.value = goodId
|
||||
}
|
||||
|
||||
function onGlobalDragOver(e: DragEvent, goodId: string) {
|
||||
if (!dragGoodId.value || dragGoodId.value === goodId) return
|
||||
e.preventDefault()
|
||||
dragOverGoodId.value = goodId
|
||||
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect()
|
||||
dragOverPos.value = e.clientY < rect.top + rect.height / 2 ? 'before' : 'after'
|
||||
}
|
||||
|
||||
function onGlobalDragLeave(_e: DragEvent, goodId: string) {
|
||||
if (dragOverGoodId.value === goodId) dragOverGoodId.value = null
|
||||
}
|
||||
|
||||
async function onGlobalDrop(_e: DragEvent) {
|
||||
const draggedId = dragGoodId.value
|
||||
const targetId = dragOverGoodId.value
|
||||
const pos = dragOverPos.value
|
||||
dragGoodId.value = null
|
||||
dragOverGoodId.value = null
|
||||
if (!draggedId || !targetId || draggedId === targetId) return
|
||||
|
||||
// Build the new order
|
||||
const nodes = [...globalGoodsNodes.value]
|
||||
const fromIdx = nodes.findIndex(n => n.goodId === draggedId)
|
||||
const toIdx = nodes.findIndex(n => n.goodId === targetId)
|
||||
if (fromIdx === -1 || toIdx === -1) return
|
||||
|
||||
const [moved] = nodes.splice(fromIdx, 1)
|
||||
let insertIdx = nodes.findIndex(n => n.goodId === targetId)
|
||||
if (pos === 'after') insertIdx++
|
||||
nodes.splice(insertIdx, 0, moved)
|
||||
|
||||
// Recalculate priorities: first item gets highest priority
|
||||
const items = nodes.map((n, i) => ({
|
||||
id: Number(n.goodId),
|
||||
priority: nodes.length - i,
|
||||
}))
|
||||
|
||||
moveTopLoading.value = 'drag'
|
||||
try {
|
||||
await goodsApi.batchUpdatePriority({ items })
|
||||
await refreshLeftTree()
|
||||
} catch {
|
||||
ElMessage.error('排序失败')
|
||||
} finally {
|
||||
moveTopLoading.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function onGlobalDragEnd() {
|
||||
dragGoodId.value = null
|
||||
dragOverGoodId.value = null
|
||||
}
|
||||
|
||||
const canDragGlobal = computed(() => {
|
||||
return sortBy.value === 'default' || sortBy.value === 'priority-desc'
|
||||
})
|
||||
|
||||
const isAllSelected = computed(() => {
|
||||
const nodes = globalGoodsNodes.value
|
||||
return nodes.length > 0 && nodes.every(n => globalSelectedIds.value.has(n.goodId))
|
||||
})
|
||||
const isIndeterminate = computed(() => {
|
||||
const c = globalGoodsNodes.value.filter(n => globalSelectedIds.value.has(n.goodId)).length
|
||||
return c > 0 && c < globalGoodsNodes.value.length
|
||||
})
|
||||
|
||||
function toggleSelectAll() {
|
||||
if (isAllSelected.value) globalSelectedIds.value.clear()
|
||||
else globalGoodsNodes.value.forEach(n => globalSelectedIds.value.add(n.goodId))
|
||||
}
|
||||
function toggleSelectItem(goodId: string) {
|
||||
if (globalSelectedIds.value.has(goodId)) globalSelectedIds.value.delete(goodId)
|
||||
else globalSelectedIds.value.add(goodId)
|
||||
}
|
||||
function clearSelection() { globalSelectedIds.value.clear() }
|
||||
|
||||
async function moveToTop(goodId: string) {
|
||||
moveTopLoading.value = goodId
|
||||
try {
|
||||
const maxPriority = Math.max(0, ...allGoods.value.map(g => g.goodPriority || 0))
|
||||
await goodsApi.batchUpdatePriority({ items: [{ id: Number(goodId), priority: maxPriority + 1 }] })
|
||||
ElMessage.success('已置顶')
|
||||
await refreshLeftTree()
|
||||
} catch { ElMessage.error('操作失败') }
|
||||
finally { moveTopLoading.value = null }
|
||||
}
|
||||
|
||||
async function batchMoveToTop() {
|
||||
const ids = [...globalSelectedIds.value]
|
||||
if (!ids.length) return
|
||||
moveTopLoading.value = 'batch'
|
||||
try {
|
||||
const maxPriority = Math.max(0, ...allGoods.value.map(g => g.goodPriority || 0))
|
||||
await goodsApi.batchUpdatePriority({
|
||||
items: ids.map((id, i) => ({ id: Number(id), priority: maxPriority + ids.length - i })),
|
||||
})
|
||||
ElMessage.success(`已置顶 ${ids.length} 个商品`)
|
||||
clearSelection()
|
||||
await refreshLeftTree()
|
||||
} catch { ElMessage.error('操作失败') }
|
||||
finally { moveTopLoading.value = null }
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
rightTreeRef.value?.filter?.('')
|
||||
}
|
||||
|
||||
onMounted(() => loadAll())
|
||||
</script>
|
||||
|
||||
@@ -808,9 +1100,9 @@ onMounted(() => loadAll())
|
||||
<div class="gv-root" v-loading="loading">
|
||||
<!-- Filter Bar -->
|
||||
<div class="gv-filter">
|
||||
<el-input v-model="searchKeyword" size="small" style="width: 160px" placeholder="搜索..." clearable>
|
||||
<template #prefix><el-icon><Search /></el-icon></template>
|
||||
</el-input>
|
||||
<el-select v-model="sortBy" size="small" style="width: 140px">
|
||||
<el-option v-for="opt in SORT_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
|
||||
<el-select v-model="selectedCountryIds" multiple collapse-tags collapse-tags-tooltip size="small" placeholder="国家筛选" style="width: 150px" popper-class="filter-popper">
|
||||
<el-option v-for="c in allCountries" :key="c.id" :label="c.countryName" :value="c.id">
|
||||
@@ -826,12 +1118,13 @@ onMounted(() => loadAll())
|
||||
placement="bottom-start"
|
||||
:width="280"
|
||||
trigger="click"
|
||||
transition="el-zoom-in-top"
|
||||
popper-class="tag-filter-popper"
|
||||
>
|
||||
<template #reference>
|
||||
<div
|
||||
class="tag-select-trigger"
|
||||
:class="{ 'is-filled': selectedTagIds.length > 0 }"
|
||||
:class="{ 'is-filled': selectedTagIds.length > 0, 'is-active': tagPopoverVisible }"
|
||||
>
|
||||
<template v-if="selectedTagIds.length === 0">
|
||||
<span class="placeholder">标签筛选</span>
|
||||
@@ -849,11 +1142,14 @@ onMounted(() => loadAll())
|
||||
</el-tag>
|
||||
<span v-if="hiddenSelectedCount > 0" class="more-tag">+{{ hiddenSelectedCount }}</span>
|
||||
</template>
|
||||
<i class="fa-solid fa-chevron-down arrow"></i>
|
||||
<el-icon class="tag-arrow"><ArrowDown /></el-icon>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="tag-tree-panel">
|
||||
<div class="tag-tree-toolbar">
|
||||
<el-button text size="small" :icon="Plus" @click="quickCreateTagGroup">新建分组</el-button>
|
||||
</div>
|
||||
<el-tree
|
||||
:data="tagTreeData"
|
||||
node-key="id"
|
||||
@@ -900,15 +1196,21 @@ onMounted(() => loadAll())
|
||||
</div>
|
||||
</el-popover>
|
||||
|
||||
<el-input v-model="searchKeyword" size="small" style="width: 160px" placeholder="搜索商品..." clearable @keyup.enter="onSearch">
|
||||
<template #prefix><el-icon><Search /></el-icon></template>
|
||||
</el-input>
|
||||
<el-button size="small" type="primary" :icon="Search" @click="onSearch">搜索</el-button>
|
||||
|
||||
<div class="gv-filter-spacer" />
|
||||
<el-radio-group v-model="mode" size="small" @change="onModeChange">
|
||||
<el-radio-button value="category">品类</el-radio-button>
|
||||
<el-radio-button value="country">国家</el-radio-button>
|
||||
<el-radio-button value="global">全局</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
|
||||
<!-- Dual Tree -->
|
||||
<div class="gv-trees">
|
||||
<!-- Dual Tree (hidden in global mode) -->
|
||||
<div v-show="mode !== 'global'" class="gv-trees">
|
||||
<!-- Left: 官网分类 + 商品 -->
|
||||
<div class="gv-panel gv-left" :style="{ width: leftPct + '%', flexShrink: 0 }">
|
||||
<div class="gv-panel-head">
|
||||
@@ -935,6 +1237,9 @@ onMounted(() => loadAll())
|
||||
@dragover="onCatDragOver($event)"
|
||||
@drop="onCatDrop($event, data)"
|
||||
>
|
||||
<el-image v-if="data.icon" :src="data.icon" fit="cover" class="cat-icon">
|
||||
<template #error><div class="cat-icon-placeholder" /></template>
|
||||
</el-image>
|
||||
<span class="cat-label">{{ data.label }}</span>
|
||||
<span v-if="data.goodCount > 0" class="cat-count">{{ data.goodCount }}</span>
|
||||
<span class="cat-actions" @click.stop>
|
||||
@@ -973,10 +1278,6 @@ onMounted(() => loadAll())
|
||||
>{{ t.tagName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gt-row">
|
||||
<div class="gt-label">优先级</div>
|
||||
<div class="gt-val">{{ data.priority }}</div>
|
||||
</div>
|
||||
<div v-if="data.originGoodName" class="gt-row">
|
||||
<div class="gt-label">原产品</div>
|
||||
<div class="gt-val gt-val-ellipsis">{{ data.originGoodName }}</div>
|
||||
@@ -993,7 +1294,8 @@ onMounted(() => loadAll())
|
||||
<el-button size="small" link type="danger" :icon="Delete" @click="handleDeleteGood(data.raw)" />
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="data.country || data.tags?.length" class="good-meta">
|
||||
<div v-if="data.country || data.tags?.length || data.originDelisted" class="good-meta">
|
||||
<span v-if="data.originDelisted" class="good-delisted-badge">下架</span>
|
||||
<span v-if="data.country" class="good-country">{{ data.country }}</span>
|
||||
<span
|
||||
v-for="t in (data.tags || []).slice(0, 3)" :key="t.id"
|
||||
@@ -1017,9 +1319,14 @@ onMounted(() => loadAll())
|
||||
<div class="gv-panel gv-right">
|
||||
<div class="gv-panel-head">
|
||||
<span>原产品库</span>
|
||||
<el-button size="small" link @click="showAllRight = !showAllRight; setExpand(rightTreeRef, rightTreeData, showAllRight)">
|
||||
{{ showAllRight ? '收起' : '展开' }}
|
||||
</el-button>
|
||||
<div style="display:flex;align-items:center;gap:6px">
|
||||
<el-button size="small" link :type="showUnconfiguredOnly ? 'primary' : ''" @click="toggleUnconfiguredFilter">
|
||||
{{ showUnconfiguredOnly ? '✓ 仅未配置' : '仅未配置' }}
|
||||
</el-button>
|
||||
<el-button size="small" link @click="showAllRight = !showAllRight; setExpand(rightTreeRef, rightTreeData, showAllRight)">
|
||||
{{ showAllRight ? '收起' : '展开' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-tree
|
||||
ref="rightTreeRef"
|
||||
@@ -1033,15 +1340,119 @@ onMounted(() => loadAll())
|
||||
<template #default="{ data }">
|
||||
<div v-if="data.isOG" class="og-node" draggable="true" @dragstart="onOGDragStart($event, data)">
|
||||
<el-image v-if="data.goodImage" :src="data.goodImage" fit="cover" class="og-thumb" />
|
||||
<div v-else class="og-thumb og-thumb-placeholder" />
|
||||
<span class="og-name">{{ data.label }}</span>
|
||||
<span
|
||||
v-if="data.configuredCount > 0"
|
||||
class="og-badge og-badge--ok"
|
||||
title="已配置 {{ data.configuredCount }} 国"
|
||||
>已配置{{ data.configuredCount > 1 ? ' ' + data.configuredCount : '' }}</span>
|
||||
<span
|
||||
v-else
|
||||
class="og-badge og-badge--warn"
|
||||
>未配置</span>
|
||||
<span v-if="data.goodPrice" class="og-price">¥{{ data.goodPrice }}</span>
|
||||
<el-button
|
||||
v-if="data.configuredCount > 0"
|
||||
size="small" link :icon="Aim" title="定位到官网商品"
|
||||
@click.stop="locateInLeftTree(data.rawId)"
|
||||
/>
|
||||
<el-button
|
||||
v-if="!data.configuredCount"
|
||||
size="small" type="primary" link class="og-config-btn"
|
||||
@click.stop="openConfigFromRightTree(data)"
|
||||
>配置</el-button>
|
||||
</div>
|
||||
<div v-else class="og-cat-node">
|
||||
<span>{{ data.label }}</span>
|
||||
<span v-if="data.totalCount" class="og-cat-count">
|
||||
<template v-if="data.configuredCount < data.totalCount">
|
||||
{{ data.configuredCount }}/{{ data.totalCount }}
|
||||
</template>
|
||||
<template v-else>{{ data.totalCount }}</template>
|
||||
</span>
|
||||
</div>
|
||||
<span v-else>{{ data.label }}</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Global Mode: flat list with same panel styling -->
|
||||
<div v-if="mode === 'global'" class="gv-panel gv-global">
|
||||
<div class="gv-panel-head">
|
||||
<template v-if="globalSelectedIds.size > 0">
|
||||
<el-checkbox :model-value="isAllSelected" :indeterminate="isIndeterminate" @change="toggleSelectAll">全选</el-checkbox>
|
||||
<span class="gl-batch-count">已选 {{ globalSelectedIds.size }} 项</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span>全部商品 ({{ globalGoodsNodes.length }})</span>
|
||||
<span v-if="!canDragGlobal" class="gl-drag-hint">切换为「默认排序」可拖拽排序</span>
|
||||
</template>
|
||||
<div style="display:flex;align-items:center;gap:6px">
|
||||
<template v-if="globalSelectedIds.size > 0">
|
||||
<el-button size="small" type="primary" :icon="Top" :loading="moveTopLoading === 'batch'" @click="batchMoveToTop">批量置顶</el-button>
|
||||
<el-button size="small" text @click="clearSelection">取消</el-button>
|
||||
</template>
|
||||
<el-button v-else size="small" link @click="setExpand(virtualContainer.ref ?? null, [], true)">展开</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gv-global-list" v-bind="virtualContainer">
|
||||
<div v-bind="virtualWrapper">
|
||||
<div
|
||||
v-for="{ data } in virtualList"
|
||||
:key="data.id"
|
||||
class="gl-item"
|
||||
:class="{
|
||||
'is-checked': globalSelectedIds.has(data.goodId),
|
||||
'is-dragging': dragGoodId === data.goodId,
|
||||
'is-drop-before': dragOverGoodId === data.goodId && dragOverPos === 'before',
|
||||
'is-drop-after': dragOverGoodId === data.goodId && dragOverPos === 'after',
|
||||
}"
|
||||
:draggable="canDragGlobal"
|
||||
@dragstart="onGlobalDragStart($event, data.goodId)"
|
||||
@dragover="onGlobalDragOver($event, data.goodId)"
|
||||
@dragleave="onGlobalDragLeave($event, data.goodId)"
|
||||
@drop="onGlobalDrop"
|
||||
@dragend="onGlobalDragEnd"
|
||||
>
|
||||
<el-checkbox
|
||||
:model-value="globalSelectedIds.has(data.goodId)"
|
||||
class="gl-checkbox"
|
||||
@change="toggleSelectItem(data.goodId)"
|
||||
@click.stop
|
||||
/>
|
||||
<el-image v-if="data.goodImage" :src="data.goodImage" fit="cover" class="gl-thumb" />
|
||||
<div v-else class="gl-thumb gl-thumb-placeholder" />
|
||||
<div class="gl-info">
|
||||
<div class="gl-name">{{ data.label }}</div>
|
||||
<div class="gl-meta">
|
||||
<span v-if="data.originDelisted" class="gl-delisted-badge">下架</span>
|
||||
<span v-if="data.country" class="gl-country">{{ data.country }}</span>
|
||||
<span
|
||||
v-for="t in (data.tags || []).slice(0, 3)" :key="t.id"
|
||||
class="gl-tag" :style="{ '--tag-color': t.tagColor || '#ccc' }"
|
||||
>{{ t.tagName }}</span>
|
||||
<span v-if="(data.tags?.length || 0) > 3" class="gl-tag-more">+{{ data.tags!.length - 3 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gl-actions">
|
||||
<el-button
|
||||
size="small" link :icon="Top"
|
||||
:loading="moveTopLoading === data.goodId"
|
||||
:title="data.priority > 0 ? '已置顶' : '置顶'"
|
||||
@click.stop="moveToTop(data.goodId)"
|
||||
/>
|
||||
<el-button size="small" link :icon="Edit" @click.stop="openEdit(data.raw)" />
|
||||
<el-button size="small" link type="danger" :icon="Delete" @click.stop="handleDeleteGood(data.raw)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="globalGoodsNodes.length === 0" class="gv-global-empty">
|
||||
<el-empty description="没有匹配的商品" :image-size="60" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Config Modal -->
|
||||
<el-dialog v-model="configVisible" title="配置原产品" width="520px" destroy-on-close>
|
||||
<div v-if="configOG" class="config-og-info">
|
||||
@@ -1052,7 +1463,7 @@ onMounted(() => loadAll())
|
||||
</div>
|
||||
<el-form label-width="80px" style="margin-top: 16px">
|
||||
<el-form-item label="国家">
|
||||
<div v-if="mode === 'category'" class="select-inline">
|
||||
<div v-if="mode === 'category' || !configDropTarget" class="select-inline">
|
||||
<el-select v-model="configForm.countryId" placeholder="请选择国家" filterable @change="loadConfigPositions">
|
||||
<el-option v-for="c in allCountries" :key="c.id" :label="c.countryName" :value="c.id" />
|
||||
</el-select>
|
||||
@@ -1061,19 +1472,18 @@ onMounted(() => loadAll())
|
||||
<el-tag v-else>{{ allCountries.find(c => c.id === configForm.countryId)?.countryName }}</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类">
|
||||
<el-cascader v-if="mode === 'country'" v-model="configForm.cascaderCategory" :options="categoryCascader" :props="{ checkStrictly: true }" placeholder="请选择分类" @change="onConfigCascaderChange" />
|
||||
<el-cascader v-if="mode === 'country' || !configDropTarget" v-model="configForm.cascaderCategory" :options="categoryCascader" :props="{ checkStrictly: true }" placeholder="请选择分类" @change="onConfigCascaderChange" style="width:100%" />
|
||||
<el-tag v-else>{{ configDropTarget?.label }}</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item label="图片">
|
||||
<div class="img-edit-row">
|
||||
<el-image v-if="configForm.goodImage" :src="configForm.goodImage" fit="cover" class="img-preview" />
|
||||
<el-input v-model="configForm.goodImage" placeholder="图片 URL(可选)" />
|
||||
</div>
|
||||
<ImageUpload v-model="configForm.goodImage" label="上传图片" />
|
||||
</el-form-item>
|
||||
<el-form-item label="标签">
|
||||
<div class="select-inline">
|
||||
<el-select v-model="configForm.tagIds" multiple filterable placeholder="选择标签" style="flex:1">
|
||||
<el-option v-for="t in allTags" :key="t.id" :label="t.tagName" :value="t.id" />
|
||||
<el-option-group v-for="g in groupedTagOptions" :key="g.id" :label="g.label">
|
||||
<el-option v-for="t in g.tags" :key="t.id" :label="t.tagName" :value="t.id" />
|
||||
</el-option-group>
|
||||
</el-select>
|
||||
<el-button text :icon="Plus" @click="quickCreateTag(() => { const latest = allTags.value[allTags.value.length - 1]; if (latest) configForm.value.tagIds.push(latest.id) })" />
|
||||
</div>
|
||||
@@ -1083,9 +1493,6 @@ onMounted(() => loadAll())
|
||||
<el-option v-for="p in configPositions" :key="p.id" :label="`#${p.indexVal}`" :value="p.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="优先级">
|
||||
<el-input-number v-model="configForm.priority" :min="0" :max="9999" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="configVisible = false">取消</el-button>
|
||||
@@ -1107,10 +1514,7 @@ onMounted(() => loadAll())
|
||||
<el-form label-width="80px" style="margin-top: 16px">
|
||||
<el-form-item label="名称"><el-input v-model="editForm.goodName" /></el-form-item>
|
||||
<el-form-item label="图片">
|
||||
<div class="img-edit-row">
|
||||
<el-image v-if="editForm.goodImage" :src="editForm.goodImage" fit="cover" class="img-preview" />
|
||||
<el-input v-model="editForm.goodImage" placeholder="图片 URL(留空则使用原产品图片)" />
|
||||
</div>
|
||||
<ImageUpload v-model="editForm.goodImage" label="上传图片" />
|
||||
</el-form-item>
|
||||
<el-form-item label="国家">
|
||||
<div class="select-inline">
|
||||
@@ -1125,13 +1529,14 @@ onMounted(() => loadAll())
|
||||
</el-form-item>
|
||||
<el-form-item label="标签">
|
||||
<div class="select-inline">
|
||||
<el-select v-model="editForm.tagIds" multiple filterable style="flex:1">
|
||||
<el-option v-for="t in allTags" :key="t.id" :label="t.tagName" :value="t.id" />
|
||||
<el-select v-model="editForm.tagIds" multiple filterable placeholder="选择标签" style="flex:1">
|
||||
<el-option-group v-for="g in groupedTagOptions" :key="g.id" :label="g.label">
|
||||
<el-option v-for="t in g.tags" :key="t.id" :label="t.tagName" :value="t.id" />
|
||||
</el-option-group>
|
||||
</el-select>
|
||||
<el-button text :icon="Plus" @click="quickCreateTag(() => { const latest = allTags.value[allTags.value.length - 1]; if (latest) editForm.value.tagIds.push(latest.id) })" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="优先级"><el-input-number v-model="editForm.priority" :min="0" :max="9999" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="danger" @click="editGood && handleDeleteGood(editGood)">删除</el-button>
|
||||
@@ -1144,7 +1549,7 @@ onMounted(() => loadAll())
|
||||
<el-dialog v-model="catEditVisible" :title="catEditMode === 'create' ? '新增分类' : '编辑分类'" width="420px" destroy-on-close>
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="名称"><el-input v-model="catEditForm.categoryName" placeholder="分类名称" /></el-form-item>
|
||||
<el-form-item label="图标"><el-input v-model="catEditForm.categoryIcon" placeholder="图标 URL(可选)" /></el-form-item>
|
||||
<el-form-item label="图标"><ImageUpload v-model="catEditForm.categoryIcon" label="上传图标" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="catEditVisible = false">取消</el-button>
|
||||
@@ -1156,7 +1561,7 @@ onMounted(() => loadAll())
|
||||
<el-dialog v-model="countryEditVisible" :title="countryEditMode === 'create' ? '新增国家' : '编辑国家'" width="420px" destroy-on-close>
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="名称"><el-input v-model="countryEditForm.countryName" placeholder="国家名称" /></el-form-item>
|
||||
<el-form-item label="图标"><el-input v-model="countryEditForm.countryIcon" placeholder="图标 URL(可选)" /></el-form-item>
|
||||
<el-form-item label="图标"><ImageUpload v-model="countryEditForm.countryIcon" label="上传图标" /></el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="countryEditVisible = false">取消</el-button>
|
||||
@@ -1233,6 +1638,77 @@ onMounted(() => loadAll())
|
||||
font-weight: 600; font-size: 14px; color: #303133;
|
||||
}
|
||||
|
||||
/* ─── Global mode ─── */
|
||||
.gv-global {
|
||||
flex: 1; min-height: 0; display: flex; flex-direction: column;
|
||||
background: #fff; border-radius: 8px; overflow: hidden;
|
||||
border: 1px solid #e4e7ed;
|
||||
}
|
||||
|
||||
.gv-global-list {
|
||||
flex: 1; min-height: 0; overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Virtual list item */
|
||||
.gl-item {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
height: 64px; padding: 0 12px;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
cursor: pointer; transition: background 0.12s;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.gl-item:hover { background: #f5f7fa; }
|
||||
.gl-item.is-checked { background: #ecf5ff; }
|
||||
.gl-item.is-dragging { opacity: 0.4; }
|
||||
.gl-item.is-drop-before { box-shadow: inset 0 2px 0 0 var(--brand-color, #ff6800); }
|
||||
.gl-item.is-drop-after { box-shadow: inset 0 -2px 0 0 var(--brand-color, #ff6800); }
|
||||
|
||||
.gl-checkbox { flex-shrink: 0; margin-right: -4px; }
|
||||
.gl-batch-count { font-size: 13px; font-weight: 600; color: var(--brand-color, #ff6800); }
|
||||
.gl-drag-hint { font-size: 11px; color: #c0c4cc; margin-left: 4px; }
|
||||
|
||||
.gl-thumb {
|
||||
width: 40px; height: 40px; border-radius: 6px; flex-shrink: 0; object-fit: cover;
|
||||
}
|
||||
.gl-thumb-placeholder {
|
||||
background: linear-gradient(135deg, #f5f7fa, #e9ecef);
|
||||
}
|
||||
.gl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
|
||||
.gl-name {
|
||||
font-size: 13px; font-weight: 500; color: #303133;
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.gl-meta { display: flex; align-items: center; gap: 4px; }
|
||||
.gl-country {
|
||||
font-size: 11px; color: #909399; line-height: 1;
|
||||
background: #f5f7fa; padding: 2px 6px; border-radius: 8px; flex-shrink: 0;
|
||||
}
|
||||
.gl-tag {
|
||||
font-size: 11px; color: #606266; line-height: 1;
|
||||
padding: 2px 6px 2px 12px; border-radius: 8px;
|
||||
background: #fafafa; position: relative; flex-shrink: 0;
|
||||
max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.gl-tag::before {
|
||||
content: ''; position: absolute; left: 5px; top: 50%;
|
||||
transform: translateY(-50%); width: 5px; height: 5px; border-radius: 50%;
|
||||
background: var(--tag-color, #ccc);
|
||||
}
|
||||
.gl-tag-more { font-size: 11px; color: #c0c4cc; flex-shrink: 0; }
|
||||
|
||||
.gl-delisted-badge {
|
||||
font-size: 10px; font-weight: 600; color: #f56c6c;
|
||||
background: #fef0f0;
|
||||
padding: 2px 8px; border-radius: 10px; flex-shrink: 0;
|
||||
}
|
||||
.gl-actions {
|
||||
display: flex; gap: 2px; flex-shrink: 0;
|
||||
opacity: 0; transition: opacity 0.15s;
|
||||
}
|
||||
.gl-item:hover .gl-actions { opacity: 1; }
|
||||
|
||||
.gv-global-empty { padding: 40px 0; }
|
||||
|
||||
/* Splitter */
|
||||
.gv-splitter {
|
||||
flex-shrink: 0; width: 8px; cursor: col-resize;
|
||||
@@ -1252,7 +1728,10 @@ onMounted(() => loadAll())
|
||||
.gv-left :deep(.el-tree-node__content > .el-tree-node__expand-icon) { flex-shrink: 0; }
|
||||
|
||||
/* Left tree: Category node */
|
||||
.cat-node { display: flex; align-items: center; flex: 1; min-width: 0; padding: 2px 8px; }
|
||||
.cat-node { display: flex; align-items: center; flex: 1; min-width: 0; padding: 2px 8px; gap: 6px; }
|
||||
.cat-icon { width: 20px; height: 20px; border-radius: 4px; flex-shrink: 0; object-fit: cover; }
|
||||
.cat-icon :deep(img) { width: 20px; height: 20px; border-radius: 4px; }
|
||||
.cat-icon-placeholder { width: 20px; height: 20px; border-radius: 4px; background: linear-gradient(135deg, #f5f7fa, #e9ecef); }
|
||||
.cat-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
|
||||
.cat-count {
|
||||
background: #f0f0f0; color: #909399; border-radius: 10px;
|
||||
@@ -1299,6 +1778,11 @@ onMounted(() => loadAll())
|
||||
background: #f5f7fa; padding: 2px 6px; border-radius: 8px;
|
||||
flex-shrink: 0; white-space: nowrap;
|
||||
}
|
||||
.good-delisted-badge {
|
||||
font-size: 11px; color: #f56c6c; line-height: 1;
|
||||
background: #fef0f0; padding: 2px 6px; border-radius: 8px;
|
||||
flex-shrink: 0; white-space: nowrap;
|
||||
}
|
||||
.good-tag {
|
||||
font-size: 11px; color: #606266; line-height: 1;
|
||||
padding: 2px 6px 2px 12px; border-radius: 8px;
|
||||
@@ -1327,8 +1811,32 @@ onMounted(() => loadAll())
|
||||
.og-node:active { cursor: grabbing; }
|
||||
.og-node:hover { background: #f5f7fa; }
|
||||
.og-thumb { width: 36px; height: 36px; border-radius: 6px; flex-shrink: 0; object-fit: cover; }
|
||||
.og-thumb-placeholder {
|
||||
background: linear-gradient(135deg, #f5f7fa, #e9ecef);
|
||||
}
|
||||
.og-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
|
||||
.og-price { color: #909399; font-size: 12px; flex-shrink: 0; }
|
||||
.og-badge {
|
||||
font-size: 10px; line-height: 1; padding: 3px 6px; border-radius: 8px;
|
||||
flex-shrink: 0; white-space: nowrap;
|
||||
}
|
||||
.og-badge--ok {
|
||||
color: #67c23a; background: #f0f9eb;
|
||||
}
|
||||
.og-badge--warn {
|
||||
color: #ff6800; background: #fff2e8;
|
||||
}
|
||||
.og-config-btn {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
.og-cat-node {
|
||||
display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
|
||||
}
|
||||
.og-cat-count {
|
||||
font-size: 10px; color: #909399; background: #f0f0f0;
|
||||
padding: 1px 6px; border-radius: 8px; flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Image edit row */
|
||||
.img-edit-row { display: flex; align-items: center; gap: 8px; width: 100%; }
|
||||
@@ -1441,21 +1949,26 @@ onMounted(() => loadAll())
|
||||
.tag-select-trigger:hover {
|
||||
border-color: #c0c4cc;
|
||||
}
|
||||
.tag-select-trigger.is-active {
|
||||
border-color: var(--brand-color);
|
||||
}
|
||||
.tag-select-trigger .placeholder {
|
||||
color: #a8abb2;
|
||||
}
|
||||
.tag-select-trigger .arrow {
|
||||
.tag-select-trigger .tag-arrow {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
color: #c0c4cc;
|
||||
transition: transform 0.2s;
|
||||
font-size: 12px;
|
||||
color: #a8abb2;
|
||||
transition: transform 0.3s ease, color 0.2s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.tag-select-trigger.is-active .tag-arrow {
|
||||
transform: rotate(180deg);
|
||||
color: var(--brand-color);
|
||||
}
|
||||
.tag-select-trigger.is-filled {
|
||||
color: #111;
|
||||
}
|
||||
.tag-select-trigger.is-filled .arrow {
|
||||
color: #909399;
|
||||
}
|
||||
.tag-select-trigger .more-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -1476,6 +1989,10 @@ onMounted(() => loadAll())
|
||||
overflow-y: auto;
|
||||
padding: 4px 0;
|
||||
}
|
||||
.tag-tree-toolbar {
|
||||
padding: 4px 8px 6px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
.tag-filter-popper .el-tree {
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Refresh, Box } from '@element-plus/icons-vue'
|
||||
import { Refresh, Box, Clock, CircleCheck, CircleClose, Loading } from '@element-plus/icons-vue'
|
||||
import type { SyncLog } from '@/types'
|
||||
import { syncApi } from '@/api/sync'
|
||||
|
||||
const logs = ref<SyncLog[]>([])
|
||||
const loading = ref(false)
|
||||
const syncing = ref(false)
|
||||
const currentType = ref<'PRODUCTS' | 'CATEGORIES'>('PRODUCTS')
|
||||
|
||||
let timer: ReturnType<typeof setInterval> | null = null
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
async function refreshLogs() {
|
||||
loading.value = true
|
||||
@@ -23,138 +25,427 @@ async function refreshLogs() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSync() {
|
||||
async function pollUntilDone(type: 'PRODUCTS' | 'CATEGORIES') {
|
||||
if (pollTimer) clearInterval(pollTimer)
|
||||
pollTimer = setInterval(async () => {
|
||||
try {
|
||||
const data = await syncApi.getSyncStatus(5) as any
|
||||
const latest = Array.isArray(data) ? data : []
|
||||
if (latest.length > 0) logs.value = [...latest, ...logs.value.slice(latest.length)]
|
||||
const top = latest.find((l: SyncLog) => l.type === type)
|
||||
if (top && top.status !== 'RUNNING') {
|
||||
if (pollTimer) { clearInterval(pollTimer); pollTimer = null }
|
||||
syncing.value = false
|
||||
if (top.status === 'SUCCESS') {
|
||||
ElMessage.success(`${type === 'PRODUCTS' ? '产品' : '分类'}同步完成`)
|
||||
} else {
|
||||
ElMessage.error(`${type === 'PRODUCTS' ? '产品' : '分类'}同步失败`)
|
||||
}
|
||||
await refreshLogs()
|
||||
}
|
||||
} catch { /* ignore poll errors */ }
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
async function handleSyncProducts() {
|
||||
await doSync('PRODUCTS')
|
||||
}
|
||||
|
||||
async function handleSyncCategories() {
|
||||
await doSync('CATEGORIES')
|
||||
}
|
||||
|
||||
async function doSync(type: 'PRODUCTS' | 'CATEGORIES') {
|
||||
const label = type === 'PRODUCTS' ? '产品' : '分类'
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'确定立即执行产品同步吗?此操作可能需要一些时间。',
|
||||
`确定立即执行${label}同步吗?${type === 'PRODUCTS' ? '此操作可能需要几分钟。' : ''}`,
|
||||
'确认',
|
||||
{ type: 'info', confirmButtonText: '执行', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch { return }
|
||||
|
||||
syncing.value = true
|
||||
currentType.value = type
|
||||
try {
|
||||
await syncApi.syncProducts()
|
||||
ElMessage.success('产品同步完成')
|
||||
await refreshLogs()
|
||||
if (type === 'PRODUCTS') {
|
||||
await syncApi.syncProducts()
|
||||
} else {
|
||||
await syncApi.syncCategories()
|
||||
}
|
||||
ElMessage.info(`${label}同步已开始`)
|
||||
pollUntilDone(type)
|
||||
} catch {
|
||||
ElMessage.error('产品同步失败')
|
||||
} finally {
|
||||
ElMessage.error(`${label}同步启动失败`)
|
||||
syncing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(s?: string): string {
|
||||
function formatTime(s?: string): string {
|
||||
if (!s) return '-'
|
||||
return new Date(s).toLocaleString()
|
||||
const d = new Date(s)
|
||||
return `${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}:${String(d.getSeconds()).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
function formatDuration(start?: string, end?: string): string | null {
|
||||
if (!start || !end) return null
|
||||
const ms = new Date(end).getTime() - new Date(start).getTime()
|
||||
if (ms < 1000) return `${ms}ms`
|
||||
return `${(ms / 1000).toFixed(1)}s`
|
||||
}
|
||||
|
||||
const stats = computed(() => {
|
||||
const total = logs.value.length
|
||||
const success = logs.value.filter(l => l.status === 'SUCCESS').length
|
||||
const failed = total - success
|
||||
const lastLog = logs.value[0]
|
||||
return { total, success, failed, lastLog }
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
refreshLogs()
|
||||
timer = setInterval(refreshLogs, 30_000)
|
||||
timer = setInterval(refreshLogs, 60_000)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (timer) clearInterval(timer)
|
||||
if (pollTimer) clearInterval(pollTimer)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="sync-cards">
|
||||
<el-card class="sync-card">
|
||||
<template #header>
|
||||
<div class="sync-card-header">
|
||||
<div class="sync-card-title">
|
||||
<el-icon><Box /></el-icon>
|
||||
<span>产品同步</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p class="sync-card-desc">
|
||||
从上游拉取最新产品和原产品并与本地数据库进行同步。
|
||||
</p>
|
||||
<el-button type="primary" :loading="syncing" @click="handleSync">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
<span>执行产品同步</span>
|
||||
<div class="sync-page" v-loading="loading">
|
||||
<!-- Action Card -->
|
||||
<div class="sync-action-card">
|
||||
<div class="sync-action-info">
|
||||
<div class="sync-action-icon">
|
||||
<el-icon :size="28"><Box /></el-icon>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="sync-action-title">数据同步</h2>
|
||||
<p class="sync-action-desc">从上游 SDS 系统拉取最新分类和产品数据并同步到本地数据库</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sync-action-buttons">
|
||||
<el-button
|
||||
size="large"
|
||||
:loading="syncing && currentType === 'CATEGORIES'"
|
||||
:disabled="syncing"
|
||||
@click="handleSyncCategories"
|
||||
>
|
||||
同步分类
|
||||
</el-button>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<div class="page-card logs-card">
|
||||
<div class="logs-toolbar">
|
||||
<h3 class="logs-title">同步日志</h3>
|
||||
<el-button @click="refreshLogs">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
<span>刷新</span>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="large"
|
||||
:loading="syncing && currentType === 'PRODUCTS'"
|
||||
:disabled="syncing"
|
||||
:icon="Refresh"
|
||||
@click="handleSyncProducts"
|
||||
>
|
||||
同步产品
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-table v-loading="loading" :data="logs" border stripe>
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }: { row: SyncLog }">
|
||||
<el-tag :type="row.status === 'SUCCESS' ? 'success' : 'danger'" size="small">
|
||||
{{ row.status === 'SUCCESS' ? '成功' : '失败' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="时间" width="200">
|
||||
<template #default="{ row }: { row: SyncLog }">
|
||||
{{ formatDate(row.startTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="message" label="信息" min-width="200" show-overflow-tooltip />
|
||||
<template #empty>
|
||||
<el-empty description="暂无同步记录" />
|
||||
</template>
|
||||
</el-table>
|
||||
<!-- Stats Row -->
|
||||
<div class="sync-stats">
|
||||
<div class="stat-item">
|
||||
<span class="stat-value">{{ stats.total }}</span>
|
||||
<span class="stat-label">总同步次数</span>
|
||||
</div>
|
||||
<div class="stat-divider" />
|
||||
<div class="stat-item">
|
||||
<span class="stat-value stat-success">{{ stats.success }}</span>
|
||||
<span class="stat-label">成功</span>
|
||||
</div>
|
||||
<div class="stat-divider" />
|
||||
<div class="stat-item">
|
||||
<span class="stat-value stat-failed">{{ stats.failed }}</span>
|
||||
<span class="stat-label">失败</span>
|
||||
</div>
|
||||
<div class="stat-divider" />
|
||||
<div class="stat-item">
|
||||
<span class="stat-value stat-time">{{ stats.lastLog ? formatTime(stats.lastLog.startTime) : '-' }}</span>
|
||||
<span class="stat-label">最近同步</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Log Timeline -->
|
||||
<div class="sync-logs">
|
||||
<div class="sync-logs-head">
|
||||
<h3 class="sync-logs-title">同步日志</h3>
|
||||
<el-button text :icon="Refresh" @click="refreshLogs">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="logs.length === 0 && !loading" class="sync-empty">
|
||||
<el-empty description="暂无同步记录" :image-size="80" />
|
||||
</div>
|
||||
|
||||
<div v-else class="sync-timeline">
|
||||
<div
|
||||
v-for="log in logs"
|
||||
:key="log.id"
|
||||
class="timeline-item"
|
||||
>
|
||||
<div class="timeline-dot" :class="log.status === 'SUCCESS' ? 'is-success' : (log.status === 'RUNNING' ? 'is-running' : 'is-failed')">
|
||||
<el-icon :size="12">
|
||||
<Loading v-if="log.status === 'RUNNING'" />
|
||||
<CircleCheck v-else-if="log.status === 'SUCCESS'" />
|
||||
<CircleClose v-else />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="timeline-content">
|
||||
<div class="timeline-header">
|
||||
<span class="timeline-type">{{ log.type === 'PRODUCTS' ? '产品' : '分类' }}</span>
|
||||
<span class="timeline-status" :class="log.status === 'SUCCESS' ? 'is-success' : (log.status === 'RUNNING' ? 'is-running' : 'is-failed')">
|
||||
{{ log.status === 'SUCCESS' ? '成功' : log.status === 'RUNNING' ? '进行中' : '失败' }}
|
||||
</span>
|
||||
<span v-if="formatDuration(log.startTime, log.endTime)" class="timeline-duration">
|
||||
<el-icon :size="11"><Clock /></el-icon>
|
||||
{{ formatDuration(log.startTime, log.endTime) }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="log.message" class="timeline-message">{{ log.message }}</p>
|
||||
<span class="timeline-time">{{ formatTime(log.startTime) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sync-cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 16px;
|
||||
.sync-page {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
/* Action Card */
|
||||
.sync-action-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 24px 28px;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #ebeef5;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.sync-card-header {
|
||||
.sync-action-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.sync-action-icon {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, #fff2e8, #ffe0c2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--brand-color, #ff6800);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sync-action-title {
|
||||
margin: 0 0 4px;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.sync-action-desc {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.sync-action-buttons {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* Stats */
|
||||
.sync-stats {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0;
|
||||
padding: 16px 28px;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #ebeef5;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: #1f2937;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.stat-value.stat-success { color: #67c23a; }
|
||||
.stat-value.stat-failed { color: #f56c6c; }
|
||||
.stat-value.stat-time { font-size: 14px; font-weight: 600; color: #606266; }
|
||||
|
||||
.stat-label {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.stat-divider {
|
||||
width: 1px;
|
||||
height: 32px;
|
||||
background: #ebeef5;
|
||||
}
|
||||
|
||||
/* Logs */
|
||||
.sync-logs {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #ebeef5;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sync-logs-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
}
|
||||
|
||||
.sync-card-title {
|
||||
.sync-logs-title {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.sync-empty {
|
||||
padding: 40px 0;
|
||||
}
|
||||
|
||||
/* Timeline */
|
||||
.sync-timeline {
|
||||
padding: 16px 20px;
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.timeline-item {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding-bottom: 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.timeline-item:not(:last-child)::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 7px;
|
||||
top: 22px;
|
||||
bottom: 0;
|
||||
width: 2px;
|
||||
background: #f0f0f0;
|
||||
}
|
||||
|
||||
.timeline-dot {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
z-index: 1;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.timeline-dot.is-success {
|
||||
background: #f0f9eb;
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.timeline-dot.is-failed {
|
||||
background: #fef0f0;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.timeline-dot.is-running {
|
||||
background: #ecf5ff;
|
||||
color: #409eff;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.timeline-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.timeline-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.sync-card-title :deep(.el-icon) {
|
||||
color: var(--brand-color);
|
||||
}
|
||||
|
||||
.sync-card-desc {
|
||||
color: #6b7280;
|
||||
.timeline-status {
|
||||
font-size: 13px;
|
||||
margin: 0 0 16px;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.logs-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.logs-title {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.timeline-status.is-success { color: #67c23a; }
|
||||
.timeline-status.is-failed { color: #f56c6c; }
|
||||
.timeline-status.is-running { color: #409eff; }
|
||||
|
||||
.timeline-type {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #606266;
|
||||
background: #f5f7fa;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.timeline-duration {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
font-size: 11px;
|
||||
color: #909399;
|
||||
background: #f5f7fa;
|
||||
padding: 2px 6px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.timeline-message {
|
||||
margin: 0 0 4px;
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.timeline-time {
|
||||
font-size: 11px;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -25,6 +25,7 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/api': {
|
||||
@@ -32,6 +33,14 @@ export default defineConfig({
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
},
|
||||
'/uploads': {
|
||||
target: 'http://localhost:3001',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/assets': {
|
||||
target: 'http://localhost:3001',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user