feat:商品分类管理

This commit is contained in:
weiwei committed 2025-09-12 15:49:25 +08:00
1 parent dcf971dd8d
commit 4b02337db3
5 files changed
+94 -4

No files matched your search

+7
View File
@@ -172,6 +172,13 @@
"navigationBarTitleText": "商品信息管理",
"disableScroll": true
}
},
{
"path": "goods-categary",
"style": {
"navigationBarTitleText": "商品分类管理",
"disableScroll": true
}
}
]
},
@@ -0,0 +1,78 @@
<template>
<crud-layout mainIsScroll bg="/static/page/blue-bg.png">
<view class="h-40rpx"></view>
<view class="card flex justify-between items-center mb-2 mx-20rpx p-4" v-for="item in categoryList" :key="item.id">
<view class="flex-row-center gap-2">
<text class="sub-text-30">{{ item.name }}</text>
<text class="c-#0094ff! sub-text-24 mr-20rpx px-2 bg-#0094ff22 rounded-2">{{ item.status == "0" ? "正常" : "禁用" }}</text>
</view>
<view class="flex-row-center gap-2">
<tm-button class="px-2" size="xs" @click="">编辑</tm-button>
<tm-button class="px-2" size="xs" :linear="['to right', '#FFC328', '#E2000099']" @click="">删除</tm-button>
</view>
</view>
<view class="h-100rpx"></view>
<view class="fixed bottom-80rpx left-40rpx">
<tm-button class="px-2" size="s" :linear="['to right', '#0779FD', '#62abff']" @click="addCategary">新增分类</tm-button>
</view>
<tm-drawer
title="分类"
:showClose="true"
:showFooter="true"
size="90%"
placement="bottom"
v-model:show="categaryFormDrawer"
:duration="100"
zIndex="100"
bgColor="#F5F5F5"
>
<view>分类名称:</view>
<tm-input v-model="form.name" type="text" :showClear="true" placeholder="请输入分类名称"></tm-input>
<view>父级分类:</view>
<shop-categary-tree :node-data="categoryTree" @currentNode="currentNode" />
</tm-drawer>
</crud-layout>
</template>
<script setup lang="ts">
import { prosperityShopApi } from "@/sheep/api"
import { onLoad } from "@dcloudio/uni-app"
import { reactive, ref } from "vue"
import ShopCategaryTree from "@/sheep/components/shop-categary-tree.vue"
const categoryList = ref<any>([])
const categaryFormDrawer = ref(false)
const form = reactive({
id: "",
name: "",
parentId: "",
})
const categoryTree = ref([])
onLoad(() => {
getGoodsCategory()
})
const getGoodsCategory = async () => {
const { code, data, msg } = await prosperityShopApi.getGoodsCategory()
if (code != 0) return uni.showToast({ title: msg || "商品分类获取失败", icon: "none" })
categoryList.value = data
}
const getCategaryTree = async () => {
const { code, data, msg } = await prosperityShopApi.getGoodsCategoryTree()
if (code != 0) return uni.showToast({ title: msg || "商品分类获取失败", icon: "none" })
categoryTree.value = data ?? []
}
const addCategary = () => {
getCategaryTree()
categaryFormDrawer.value = true
}
const currentNode = (item) => {
form.parentId = item.categoryId
}
</script>
+2 -2
View File
@@ -230,8 +230,8 @@ const getGoodsDetail = async (id: string) => {
const skuList = data.skuList.map((item: any) => ({ ...item, status: item.status.toString() }))
const coverImage = [{ path: filePath(data.coverImage), response: JSON.stringify({ data: { url: data.coverImage } }) }]
const categoryName = categoryList.value.find((item: any) => item.id == data.categoryId)?.name
const saleStartTime = data.saleStartTime.split(" ")[0]
const saleEndTime = data.saleEndTime.split(" ")[0]
const saleStartTime = data.saleStartTime
const saleEndTime = data.saleEndTime
_saleStartTimeStr.value = saleStartTime
_saleEndTimeStr.value = saleEndTime
Object.assign(form, {
+6 -1
View File
@@ -99,7 +99,7 @@
</z-paging>
<view class="fixed bottom-80rpx left-40rpx flex-col gap-2">
<tm-button class="px-2" size="s" :linear="['to right', '#0779FD', '#62abff']" @click="addGoods">新增商品</tm-button>
<tm-button class="px-2" size="s" :linear="['to right', '#0779FD', '#62abff']">分类管理</tm-button>
<tm-button class="px-2" size="s" :linear="['to right', '#0779FD', '#62abff']" @click="categaryManage">分类管理</tm-button>
</view>
</crud-layout>
</template>
@@ -192,6 +192,11 @@ const deleteGoods = (id: string) => {
},
})
}
// 分类管理
const categaryManage = () => {
uni.navigateTo({ url: "/pages/prosperity-shop/goods-categary" })
}
</script>
<style scoped lang="scss">
@@ -12,7 +12,7 @@
<script setup lang="ts">
import { ref } from "vue"
import ShopCategaryTree from "./shop-categary-tree.vue"
import ShopCategaryTree from "@/sheep/components/shop-categary-tree.vue"
defineProps({
categoryTree: {