From a5d6d18b6a31aa8739c49d1b50586e4c12d5a0b8 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 10 Jan 2024 13:51:00 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=93=96=20MALL=EF=BC=9A=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E7=9A=84=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 8 +- src/views/mall/product/spu/index.vue | 134 ++++++++++++++------------- 2 files changed, 74 insertions(+), 68 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 771bb7a4..90e1f06c 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -194,10 +194,10 @@ export const copyValueToTarget = (target, source) => { * 将一个整数转换为分数保留两位小数 * @param num */ -export const formatToFraction = (num: number | string | undefined): number => { - if (typeof num === 'undefined') return 0 +export const formatToFraction = (num: number | string | undefined): string => { + if (typeof num === 'undefined') return '0.00' const parsedNumber = typeof num === 'string' ? parseFloat(num) : num - return parseFloat((parsedNumber / 100).toFixed(2)) + return (parsedNumber / 100.0).toFixed(2) } /** @@ -249,7 +249,7 @@ export const yuanToFen = (amount: string | number): number => { /** * 分转元 */ -export const fenToYuan = (price: string | number): number => { +export const fenToYuan = (price: string | number): string => { return formatToFraction(price) } diff --git a/src/views/mall/product/spu/index.vue b/src/views/mall/product/spu/index.vue index 27a4bd2d..6817323b 100644 --- a/src/views/mall/product/spu/index.vue +++ b/src/views/mall/product/spu/index.vue @@ -1,3 +1,4 @@ + - - + + - - - + + - - + @@ -236,48 +243,41 @@ defineOptions({ name: 'ProductSpu' }) const message = useMessage() // 消息弹窗 const { t } = useI18n() // 国际化 -const { currentRoute, push } = useRouter() // 路由跳转 +const { push } = useRouter() // 路由跳转 const loading = ref(false) // 列表的加载中 const exportLoading = ref(false) // 导出的加载中 const total = ref(0) // 列表的总页数 -const list = ref([]) // 列表的数据 +const list = ref([]) // 列表的数据 // tabs 数据 const tabsData = ref([ { - count: 0, - name: '出售中商品', - type: 0 + name: '出售中', + type: 0, + count: 0 }, { - count: 0, - name: '仓库中商品', - type: 1 + name: '仓库中', + type: 1, + count: 0 }, { - count: 0, - name: '已售罄商品', - type: 2 + name: '已售罄', + type: 2, + count: 0 }, { - count: 0, name: '警戒库存', - type: 3 + type: 3, + count: 0 }, { - count: 0, - name: '商品回收站', - type: 4 + name: '回收站', + type: 4, + count: 0 } ]) -/** 获得每个 Tab 的数量 */ -const getTabsCount = async () => { - const res = await ProductSpuApi.getTabsCount() - for (let objName in res) { - tabsData.value[Number(objName)].count = res[objName] - } -} const queryParams = ref({ pageNo: 1, pageSize: 10, @@ -288,11 +288,6 @@ const queryParams = ref({ }) // 查询参数 const queryFormRef = ref() // 搜索的表单Ref -const handleTabClick = (tab: TabsPaneContext) => { - queryParams.value.tabType = tab.paneName as number - getList() -} - /** 查询列表 */ const getList = async () => { loading.value = true @@ -305,8 +300,22 @@ const getList = async () => { } } +/** 切换 Tab */ +const handleTabClick = (tab: TabsPaneContext) => { + queryParams.value.tabType = tab.paneName as number + getList() +} + +/** 获得每个 Tab 的数量 */ +const getTabsCount = async () => { + const res = await ProductSpuApi.getTabsCount() + for (let objName in res) { + tabsData.value[Number(objName)].count = res[objName] + } +} + /** 添加到仓库 / 回收站的状态 */ -const handleStatus02Change = async (row, newStatus: number) => { +const handleStatus02Change = async (row: any, newStatus: number) => { try { // 二次确认 const text = newStatus === ProductSpuStatusEnum.RECYCLE.status ? '加入到回收站' : '恢复到仓库' @@ -322,7 +331,7 @@ const handleStatus02Change = async (row, newStatus: number) => { } /** 更新上架/下架状态 */ -const handleStatusChange = async (row) => { +const handleStatusChange = async (row: any) => { try { // 二次确认 const text = row.status ? '上架' : '下架' @@ -407,19 +416,16 @@ const handleExport = async () => { } } -const categoryList = ref() // 分类树 /** 获取分类的节点的完整结构 */ -const formatCategoryName = (categoryId) => { +const categoryList = ref() // 分类树 +const formatCategoryName = (categoryId: number) => { return treeToString(categoryList.value, categoryId) } -// 监听路由变化更新列表,解决商品保存后,列表不刷新的问题。 -watch( - () => currentRoute.value, - () => { - getList() - } -) +/** 激活时 */ +onActivated(() => { + getList() +}) /** 初始化 **/ onMounted(async () => { From f1c858b9af7c098db70172eb5272c4ae0a864543 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 10 Jan 2024 23:50:19 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=F0=9F=93=96=20MALL=EF=BC=9A=E5=95=86?= =?UTF-8?q?=E5=93=81=E7=BC=96=E8=BE=91=E7=9A=84=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 - src/api/mall/product/spu.ts | 6 - .../product/spu/form/ActivityOrdersSort.vue | 66 ----- .../mall/product/spu/form/BasicInfoForm.vue | 277 ++++-------------- .../product/spu/form/OtherSettingsForm.vue | 135 +-------- src/views/mall/product/spu/form/SkuForm.vue | 240 +++++++++++++++ src/views/mall/product/spu/form/index.vue | 30 +- src/views/mall/product/spu/form/spu.data.ts | 29 -- 8 files changed, 330 insertions(+), 455 deletions(-) delete mode 100644 src/views/mall/product/spu/form/ActivityOrdersSort.vue create mode 100644 src/views/mall/product/spu/form/SkuForm.vue diff --git a/package.json b/package.json index 2bf975ca..5cdca2af 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "pinia": "^2.1.7", "qrcode": "^1.5.3", "qs": "^6.11.2", - "sortablejs": "^1.15.0", "steady-xml": "^0.1.0", "url": "^0.11.3", "video.js": "^7.21.5", @@ -81,7 +80,6 @@ "@types/nprogress": "^0.2.3", "@types/qrcode": "^1.5.5", "@types/qs": "^6.9.10", - "@types/sortablejs": "^1.15.5", "@typescript-eslint/eslint-plugin": "^6.11.0", "@typescript-eslint/parser": "^6.11.0", "@unocss/transformer-variant-group": "^0.57.4", diff --git a/src/api/mall/product/spu.ts b/src/api/mall/product/spu.ts index 8ccd02a5..61bfe21e 100644 --- a/src/api/mall/product/spu.ts +++ b/src/api/mall/product/spu.ts @@ -48,11 +48,6 @@ export interface Spu { sort?: number // 商品排序 giveIntegral?: number // 赠送积分 virtualSalesCount?: number // 虚拟销量 - recommendHot?: boolean // 是否热卖 - recommendBenefit?: boolean // 是否优惠 - recommendBest?: boolean // 是否精品 - recommendNew?: boolean // 是否新品 - recommendGood?: boolean // 是否优品 price?: number // 商品价格 salesCount?: number // 商品销量 marketPrice?: number // 市场价 @@ -60,7 +55,6 @@ export interface Spu { stock?: number // 商品库存 createTime?: Date // 商品创建时间 status?: number // 商品状态 - activityOrders: number[] // 活动排序 } // 获得 Spu 列表 diff --git a/src/views/mall/product/spu/form/ActivityOrdersSort.vue b/src/views/mall/product/spu/form/ActivityOrdersSort.vue deleted file mode 100644 index 3a41b3c5..00000000 --- a/src/views/mall/product/spu/form/ActivityOrdersSort.vue +++ /dev/null @@ -1,66 +0,0 @@ - - diff --git a/src/views/mall/product/spu/form/BasicInfoForm.vue b/src/views/mall/product/spu/form/BasicInfoForm.vue index f7da536d..42059718 100644 --- a/src/views/mall/product/spu/form/BasicInfoForm.vue +++ b/src/views/mall/product/spu/form/BasicInfoForm.vue @@ -7,131 +7,62 @@ :rules="rules" label-width="120px" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 单规格 - 多规格 - - - - - - - 默认设置 - 单独设置 - - - - - - - - - - 添加属性 - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -161,30 +92,15 @@ @click="imagePreview(row.sliderPicUrls)" /> - - - - diff --git a/src/views/mall/product/spu/form/index.vue b/src/views/mall/product/spu/form/index.vue index 9d69923a..73225e03 100644 --- a/src/views/mall/product/spu/form/index.vue +++ b/src/views/mall/product/spu/form/index.vue @@ -1,7 +1,7 @@