From 7099bea338708d40a814ba2da31fa2a8bf40d454 Mon Sep 17 00:00:00 2001 From: zc <2064281269@qq.com> Date: Wed, 5 Nov 2025 11:29:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/modules/user.ts | 3 +- .../detail-dialog/choose-file-method.ts | 9 ++- .../commodity/detail-dialog/edit-method.ts | 47 ++++++++++- .../goods/commodity/detail-dialog/index.vue | 78 +++++++++++++++++-- .../commodity/detail-dialog/use-method.ts | 6 +- src/views/login/index.vue | 6 +- 6 files changed, 136 insertions(+), 13 deletions(-) diff --git a/src/stores/modules/user.ts b/src/stores/modules/user.ts index cab57b5..4c019dc 100644 --- a/src/stores/modules/user.ts +++ b/src/stores/modules/user.ts @@ -19,9 +19,10 @@ const useUserStore = defineStore('user', { this.$reset() }, // 登录 - onLogin(data: { tokenValue: string; tokenName: string }) { + onLogin(data: { tokenValue: string; tokenName: string; userNickName: string }) { this.tokenValue = data.tokenValue this.tokenName = data.tokenName + this.userNickName = data.userNickName }, // 获取用户信息(昵称、头像、角色集合、权限集合) getUserRoleInfo() { diff --git a/src/views/goods/commodity/detail-dialog/choose-file-method.ts b/src/views/goods/commodity/detail-dialog/choose-file-method.ts index 60623a9..830f384 100644 --- a/src/views/goods/commodity/detail-dialog/choose-file-method.ts +++ b/src/views/goods/commodity/detail-dialog/choose-file-method.ts @@ -5,6 +5,8 @@ interface PreviewItem { type: 'image' | 'video' } +export const curPropertyTypeImage = ref(null) + // 选择资源库图片 export const useImportFile = (fileList: Ref) => { const showFileExplorer = ref(false) @@ -18,10 +20,15 @@ export const useImportFile = (fileList: Ref) => { // 处理文件选择 const handleChooseResourceFileCallback = (files: PreviewItem[] = []) => { - handleChooseFiles(curFileType.value, files, fileList.value) + if (curPropertyTypeImage.value) { + curPropertyTypeImage.value.imageUrl = files[0].resourceUrl + } else { + handleChooseFiles(curFileType.value, files, fileList.value) + } } const onClickChooseResourceBtn = (type: 'mainImageUrl' | 'videoUrl' | 'subImageUrl') => { + curPropertyTypeImage.value = null curFileType.value = type showFileExplorer.value = true } diff --git a/src/views/goods/commodity/detail-dialog/edit-method.ts b/src/views/goods/commodity/detail-dialog/edit-method.ts index a7be0f4..b6d9504 100644 --- a/src/views/goods/commodity/detail-dialog/edit-method.ts +++ b/src/views/goods/commodity/detail-dialog/edit-method.ts @@ -21,7 +21,11 @@ export const handleGetDialogData = ( result.adminCategoryId = defaultCheckedNodes.value.admin.slice(-1)[0] defaultCheckedNodes.value.app = [data.appCategoryId1, data.appCategoryId2] result.isTest = data.isTest + result.isNew = data.isNew + result.isFlash = data.isFlash result.title = data.title + result.frontPage = data.frontPage + result.status = data.status result.feature1 = data.feature1 result.feature2 = data.feature2 result.htmlContent = data.vvProductDetailList.find((item: any) => item.type === 2)?.detail || '' @@ -86,7 +90,7 @@ export const handleGetNewAdminCategoryData = (data: any) => { // 编辑的时候对sku进行重组 export const handleGetNewSkuList = (data: any) => { - return data.map((item: any) => { + const arr = data.map((item: any) => { let categoryPropertyNames = '' let name = '' item.vvSkuPropertyValueList.forEach((child: any, index: number) => { @@ -101,4 +105,45 @@ export const handleGetNewSkuList = (data: any) => { categoryPropertyNames } }) + return sortByPrefix(arr) +} + +/** + * 按照 name 字段的前缀进行排序,将前几位相同的项排序到一起 + * @param arr 要排序的数组 + * @returns 排序后的新数组 + */ +export const sortByPrefix = (arr: T[]): T[] => { + if (!Array.isArray(arr) || arr.length === 0) { + return arr + } + + // 计算前缀:如果 name 包含 "-",取最后一个 "-" 之前的部分作为前缀 + const getPrefix = (name: string): string => { + if (!name) return '' + + // 找到最后一个 "-" 的位置,取之前的部分作为前缀 + const lastDashIndex = name.lastIndexOf('-') + if (lastDashIndex > 0) { + return name.substring(0, lastDashIndex + 1) // 包含 "-" 分隔符 + } + + // 如果没有 "-",返回整个字符串 + return name + } + + // 创建副本并排序 + return [...arr].sort((a, b) => { + const prefixA = getPrefix(a.name || '') + const prefixB = getPrefix(b.name || '') + + // 先按前缀排序 + const prefixCompare = prefixA.localeCompare(prefixB, 'zh-CN') + if (prefixCompare !== 0) { + return prefixCompare + } + + // 如果前缀相同,再按完整的 name 排序 + return (a.name || '').localeCompare(b.name || '', 'zh-CN') + }) } diff --git a/src/views/goods/commodity/detail-dialog/index.vue b/src/views/goods/commodity/detail-dialog/index.vue index a0d7cfb..8fc8da0 100644 --- a/src/views/goods/commodity/detail-dialog/index.vue +++ b/src/views/goods/commodity/detail-dialog/index.vue @@ -77,9 +77,6 @@ > - - -
+
+ + + + + + + + + + + + + + + {{ child.categoryPropertyValue }} + + +
+ + 资源库导入 + 清空 +
{{ child.categoryPropertyValue }} ({} as Atrans$DialogRes) @@ -275,7 +327,11 @@ const init = async () => { appCategoryId: '', adminCategoryId: '', isTest: 0, - title: '' + isNew: 0, + isFlash: 0, + title: '', + frontPage: 0, + status: 'down' } adminCategoryData.value = [] skuList.value = [] @@ -378,5 +434,11 @@ init() } color: #666; } + .property-type-tag { + :deep(.el-tag__content) { + display: flex; + align-items: center; + } + } } diff --git a/src/views/goods/commodity/detail-dialog/use-method.ts b/src/views/goods/commodity/detail-dialog/use-method.ts index 0c9ff1c..43b2932 100644 --- a/src/views/goods/commodity/detail-dialog/use-method.ts +++ b/src/views/goods/commodity/detail-dialog/use-method.ts @@ -319,7 +319,7 @@ export const generateSkuList = (categories: CategoryDataMock): TSkuList[] => { return combos.map((combo) => { const serialNo = combo.map((opt) => opt.id.toString()).join('-') const name = combo.map((opt) => String(opt.categoryPropertyValue)).join('-') - const categoryPropertyNames = combo.map((opt) => String(opt.categoryPropertyValue)).join('-') + const categoryPropertyNames = combo.map((opt) => String(opt.categoryPropertyName)).join('-') const originArray = combo return { serialNo, @@ -352,3 +352,7 @@ const generateAddSkuList = ( }) return generateSkuList(filterCategoryData) } + +export const onChangePropertyTypeImage = (child: any) => { + console.log(1111, child) +} diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 8b81e24..bd3240c 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -21,7 +21,11 @@ const handleLogin = () => { if (valid) { api.login.login.post(loginData).then((res) => { router.push({ path: '/home' }) - user.onLogin({ tokenValue: res.data.token, tokenName: 'mmToken' }) + user.onLogin({ + tokenValue: res.data.token, + tokenName: 'mmToken', + userNickName: res.data.username + }) }) } else { return false