提交 7d7037e0 authored 作者: 袁伟伟's avatar 袁伟伟

feat: 商品详情页

上级 f5a19fe9
...@@ -33,7 +33,7 @@ export const usePagination = (fun: () => void) => { ...@@ -33,7 +33,7 @@ export const usePagination = (fun: () => void) => {
return reactive(p); return reactive(p);
}; };
const getNavTree = (navList, init?: Function, str) => { const getNavTree = (navList, init?: Function, str?: string) => {
goodsCategoryApi.dealerTree({ parentId: 0 }).then((res) => { goodsCategoryApi.dealerTree({ parentId: 0 }).then((res) => {
navList.value = res; navList.value = res;
userStore.setUserNavList(navList.value); userStore.setUserNavList(navList.value);
...@@ -47,7 +47,7 @@ const getNavTree = (navList, init?: Function, str) => { ...@@ -47,7 +47,7 @@ const getNavTree = (navList, init?: Function, str) => {
}); });
}; };
const navTree = (navList, init?: Function, str) => { const navTree = (navList, init?: Function, str?: string) => {
const navListStore = userStore.getNavList; const navListStore = userStore.getNavList;
if (navListStore.length <= 0) { if (navListStore.length <= 0) {
getNavTree(navList, init, str); getNavTree(navList, init, str);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</div> </div>
<div class="tableWrap"> <div class="tableWrap">
<div class="titleWrap"> <div class="titleWrap">
<span class="title">商品分类</span> <span class="title">商品价格</span>
<a-button type="primary" @click="handleAdd">新增</a-button> <a-button type="primary" @click="handleAdd">新增</a-button>
</div> </div>
<a-table :dataSource="dataSource" :columns="columns" :pagination="pagination" :loading="tableLoading"> <a-table :dataSource="dataSource" :columns="columns" :pagination="pagination" :loading="tableLoading">
......
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
const fetchId = lastFetchId; const fetchId = lastFetchId;
goodsOptions.value = []; goodsOptions.value = [];
fetching.value = true; fetching.value = true;
GoodsApi.search({ pageNum: 1, pageSize: 20, goodsName: value }).then((body) => { GoodsApi.search({ pageNum: 1, pageSize: 20, name: `%${value}%` }).then((body) => {
if (fetchId !== lastFetchId) { if (fetchId !== lastFetchId) {
return; return;
} }
......
...@@ -26,6 +26,13 @@ ...@@ -26,6 +26,13 @@
<a-form-item label="商品描述" name="remark"> <a-form-item label="商品描述" name="remark">
<a-input v-model:value="formData.remark" /> <a-input v-model:value="formData.remark" />
</a-form-item> </a-form-item>
<a-form-item label="商品类型" name="status">
<a-radio-group v-model:value="formData.goodsType">
<a-radio value="KIT">套件</a-radio>
<a-radio value="PRODUCT">商品</a-radio>
<a-radio value="SURGICAL_BAG">手术包</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="上架" name="status"> <a-form-item label="上架" name="status">
<a-radio-group v-model:value="formData.status"> <a-radio-group v-model:value="formData.status">
<a-radio value="YES"></a-radio> <a-radio value="YES"></a-radio>
...@@ -82,6 +89,7 @@ ...@@ -82,6 +89,7 @@
const formData = reactive<BasicData>({ const formData = reactive<BasicData>({
goodsCategoryList: [], goodsCategoryList: [],
name: '', name: '',
goodsType: 'PRODUCT',
status: 'NO', status: 'NO',
isImport: 'NO', isImport: 'NO',
isNews: 'NO', isNews: 'NO',
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</div> </div>
<div class="tableWrap"> <div class="tableWrap">
<div class="titleWrap"> <div class="titleWrap">
<span class="title">商品分类</span> <span class="title">商品列表</span>
<a-button type="primary" @click="handleAdd(false)">新增</a-button> <a-button type="primary" @click="handleAdd(false)">新增</a-button>
</div> </div>
<a-table :dataSource="dataSource" :columns="columns" :pagination="pagination" :loading="tableLoading"> <a-table :dataSource="dataSource" :columns="columns" :pagination="pagination" :loading="tableLoading">
......
...@@ -10,6 +10,7 @@ export interface BasicData { ...@@ -10,6 +10,7 @@ export interface BasicData {
goodsCategoryList: number[] | goodsCategory[]; goodsCategoryList: number[] | goodsCategory[];
name: string; name: string;
status: string; status: string;
goodsType: string;
isImport: string; isImport: string;
isNews: string; isNews: string;
isUnconventional: string; isUnconventional: string;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
import { emit } from 'process'; import { emit } from 'process';
import { ref, defineProps, defineEmits } from 'vue'; import { ref, defineProps, defineEmits } from 'vue';
const props = defineProps(['pageNum', 'pageSize', 'total']); const props = defineProps(['pageNum', 'pageSize', 'total']);
const emits = defineEmits(['update:pageNum', 'update:pageSize']); const emits = defineEmits(['update:pageNum', 'update:pageSize', 'handleChange']);
const handleChange = (page, pageSize) => { const handleChange = (page, pageSize) => {
emits('update:pageNum', page); emits('update:pageNum', page);
}; };
......
<template> </template> <template>
<div class="containe">
<Search></Search>
<div class="contentWrap">
<div class="top">
<div class="title">{{ title }}</div>
<div class="wrap">
<Nav v-model:navList="navList" v-model:navActiveKey="navActiveKey" />
</div>
</div>
<div class="goodsInfo">
<div class="imgWrap">
<div class="show">
<img src="../home/1.jpg" alt="" />
</div>
<ul>
<li>
<img src="../home/1.jpg" alt="" />
</li>
<li>
<img src="../home/2.png" alt="" />
</li>
</ul>
</div>
<div></div>
</div>
</div>
</div>
</template>
<script lang="ts" setup></script> <script lang="ts" setup>
import { ref, onMounted, watch } from 'vue';
import { useRoute } from 'vue-router';
import { useNavTree } from '/@/hooks/myhooks/index';
import { toNumber } from 'lodash';
import Search from '../components/search.vue';
import Nav from '../components/nav.vue';
import { DataItem } from '/@/views/product/goods-category/type';
<style scoped lang="less"></style> const route = useRoute();
const navTree = useNavTree();
const query = route.query;
const navId = toNumber(query.nav); // 一级选择id
const navList = ref<DataItem[]>([]); // 菜单树
const navActiveKey = ref(navId); // 一级标签选择
const title = ref('');
const getGrandsonList = (arr: DataItem[]) => {
arr.some((item) => {
if (item.id === navId) {
title.value = item.name;
return true;
}
});
};
onMounted(() => {
navTree(navList, getGrandsonList, 'getGrandsonList');
});
</script>
<style scoped lang="less">
.containe {
padding: 30px;
.contentWrap {
padding: 30px;
background: #fff;
border-radius: 10px;
max-width: 1400px;
min-width: 1200px;
margin: 0 auto;
.top {
display: flex;
justify-content: space-between;
.title {
width: 25%;
background: #f7f9fa;
color: #1890ff;
border-radius: 10px;
text-align: center;
height: 50px;
padding: 5px;
line-height: 40px;
font-size: 20px;
}
.wrap {
width: 73%;
margin: 0;
}
}
.goodsInfo {
.imgWrap {
.show {
width: 400px;
height: 400px;
border: 1px solid #eee;
}
}
}
}
}
</style>
...@@ -41,8 +41,9 @@ ...@@ -41,8 +41,9 @@
</div> </div>
<div class="goodsWrap"> <div class="goodsWrap">
<ul class="goodsList"> <ul class="goodsList">
<li class="goods" v-for="item in goodsList" :key="item.id"> <li class="goods" v-for="item in goodsList" :key="item.id" @click="handleChangeGoods(item)">
<div class="img"> <div class="img">
<img :src="newPng" alt="" class="new" v-if="item.isNews === 'YES'" />
<img :src="item.pic" alt="" /> <img :src="item.pic" alt="" />
</div> </div>
<p class="title">{{ item.name }}</p> <p class="title">{{ item.name }}</p>
...@@ -67,6 +68,7 @@ ...@@ -67,6 +68,7 @@
import { DataItem } from '/@/views/product/goods-category/type'; import { DataItem } from '/@/views/product/goods-category/type';
import { Goods } from '/@/views/store/goodsList/type'; import { Goods } from '/@/views/store/goodsList/type';
import * as GoodsApi from '/@/api/product/goodsApi'; import * as GoodsApi from '/@/api/product/goodsApi';
import newPng from '/@/assets/images/new.png';
const go = useGo(); const go = useGo();
const route = useRoute(); const route = useRoute();
...@@ -147,6 +149,11 @@ ...@@ -147,6 +149,11 @@
}); });
}; };
// 点击商品
const handleChangeGoods = (goods: Goods) => {
go('/main/store/goodDetail' + `?goods=${goods.id}&nav=${navId}`);
};
watch( watch(
() => navActiveKey.value, () => navActiveKey.value,
(n) => { (n) => {
...@@ -176,6 +183,7 @@ ...@@ -176,6 +183,7 @@
background: #fff; background: #fff;
border-radius: 10px; border-radius: 10px;
max-width: 1400px; max-width: 1400px;
min-width: 1200px;
margin: 0 auto; margin: 0 auto;
.top { .top {
...@@ -249,6 +257,7 @@ ...@@ -249,6 +257,7 @@
width: 25%; width: 25%;
padding: 20px 20px 5px 20px; padding: 20px 20px 5px 20px;
border: 1px solid rgb(214, 214, 214); border: 1px solid rgb(214, 214, 214);
position: relative;
&:hover { &:hover {
background: #eee; background: #eee;
...@@ -256,7 +265,15 @@ ...@@ -256,7 +265,15 @@
} }
.img { .img {
position: relative;
height: 285px; height: 285px;
.new {
position: absolute;
right: 10px;
top: 10px;
width: 50px;
height: 50px;
}
} }
.title { .title {
......
...@@ -10,4 +10,5 @@ export interface Goods { ...@@ -10,4 +10,5 @@ export interface Goods {
id: number; id: number;
pic: string; pic: string;
name: string; name: string;
isNews: string;
} }
...@@ -174,6 +174,9 @@ ...@@ -174,6 +174,9 @@
padding: 30px; padding: 30px;
background: #fff; background: #fff;
border-radius: 10px; border-radius: 10px;
max-width: 1400px;
min-width: 1200px;
margin: 0 auto;
.top { .top {
display: flex; display: flex;
...@@ -319,7 +322,7 @@ ...@@ -319,7 +322,7 @@
justify-content: space-between; justify-content: space-between;
flex-wrap: wrap; flex-wrap: wrap;
.goods { .goods {
width: 30%; width: 32%;
margin-top: 15px; margin-top: 15px;
cursor: pointer; cursor: pointer;
padding: 10px; padding: 10px;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论