feat(shopGoods): 优化商品列表和后端排序逻辑

- 商品列表「编号」列移除,改为名称下方灰色小字显示编号
- 市场价、价格、会员价三列合并为单列,按编辑弹窗顺序堆叠显示
- 后端新增 is_top 字段,实现置顶商品排序优先级调整
- pageRel 和 listRel 默认排序改为置顶优先、排序号次之、创建时间最后
- 采集默认设置 isTop 字段为 0,保持一致性
- 删除单独「编号」列节省列表横向空间,布局更紧凑
- 后端排序调整影响所有调用分页接口的端,置顶商品浮至最前
- 编辑弹窗「套餐价格」更名「进货价格」,对应接口字段注释同步修改
This commit is contained in:
2026-07-24 11:17:35 +08:00
parent e2f6dce7a1
commit a831dce61a
4 changed files with 49 additions and 35 deletions

View File

@@ -13,3 +13,20 @@
- 「排序号」列开启 `sorter: true`(之前只展示、不可排序)。
- 后端迁移脚本 `add-is-top-shop-goods.sql`:新增 `is_top` TINYINT 字段;分页默认排序需改为 `ORDER BY is_top DESC, sort_number ASC, create_time DESC`(后端不在本仓库,需手动改 page 接口 ORDER BY / 放开 orders 白名单)。
- 注意:置顶真正"排到最前"依赖后端默认排序改动;点击列排序也需后端放开 is_top / sort_number。
## 后端改动(/Users/gxwebsoft/JAVA/guilixu-javaSpring Boot + MyBatis-Plus
- `entity/ShopGoods.java`:新增 `private Integer isTop;`(映射列 is_top沿用 camelCase→下划线策略mapper 用 SELECT a.*,无需改 XML
- `service/impl/ShopGoodsServiceImpl.java`
- `pageRel``listRel` 默认排序由 `sort_number asc, create_time desc` 改为 `is_top desc, sort_number asc, create_time desc`(置顶优先,置顶内按排序号,其余按创建时间倒序)。
- `collectFromUrl` 采集默认值补 `goods.setIsTop(0)`(与 recommend 一致)。
- 排序字段无白名单:`PageParam` 直接按列名拼 ORDER BY前端点「置顶」「排序号」列排序无需额外放开。
- DB 仍需执行 `add-is-top-shop-goods.sql`(在 admin 仓库根目录):`ALTER TABLE shop_goods ADD COLUMN is_top TINYINT(1) NOT NULL DEFAULT 0`
- 副作用提醒:默认排序改为置顶优先会影响所有调用 pageRel/listRel 的端(含小程序商品列表),置顶商品会浮到最前——通常正是期望行为。
## shopGoods 列表:商品编号移到名称下方
- `src/views/shop/shopGoods/index.vue`:删除独立的「编号」列(原 `code` 列),改为在「商品」列的名称下方显示「编号:{{ record.code }}」(灰色小字),节省一列横向空间。无 code 时不渲染该行。
## shopGoods 列表:三个价格合并为一列 + 与编辑弹窗对齐
- 原「市场价/价格/会员价」三列(字段 salePrice/price/dealerPrice合并为单个「价格」列`key: 'priceGroup'`width 150
- 单元格内堆叠显示,顺序与命名对齐编辑弹窗(`shopGoodsEdit.vue` 基本信息 Tab价格price加粗头条→ 市场价salePrice→ 会员价dealerPrice空值显示 `-`
- 列表展示用 priceGroup 自定义 `#bodyCell` 渲染;导出 Excel`handleExport`)仍保留三列独立价格,未改动。

View File

@@ -44,7 +44,7 @@ export interface ShopGoods {
commissionRole?: number;
// 货架
position?: string;
// 套餐价格
// 进货价格
buyingPrice?: string;
// 商品价格
price?: string;

View File

@@ -98,9 +98,9 @@
v-model:value="form.dealerPrice"
/>
</a-form-item>
<a-form-item label="套餐价格" name="originPrice">
<a-form-item label="进货价格" name="originPrice">
<a-input-number
:placeholder="`套餐价格`"
:placeholder="`进货价格`"
style="width: 240px"
:min="0.01"
v-model:value="form.buyingPrice"
@@ -1337,7 +1337,7 @@ const rules = reactive({
price: [
{
required: true,
message: '请填写会员价',
message: '请填写商品价格',
type: 'number',
trigger: 'blur'
}
@@ -1353,7 +1353,7 @@ const rules = reactive({
buyingPrice: [
{
required: true,
message: '请填写会员店/总仓批发价',
message: '请填写进货价',
type: 'number',
trigger: 'blur'
}

View File

@@ -41,9 +41,31 @@
:preview="false"
:width="50"
/>
<span class="text-gray-700 font-bold">{{ record.name }}</span>
<div class="flex flex-col justify-center leading-tight">
<span class="text-gray-700 font-bold">{{ record.name }}</span>
<span
v-if="record.code"
class="text-gray-400 text-xs mt-1"
>编号{{ record.code }}</span
>
</div>
</a-space>
</template>
<template v-if="column.key === 'priceGroup'">
<div class="flex flex-col leading-tight gap-0.5">
<span class="text-gray-800 font-bold">{{ record.price }}</span>
<span class="text-gray-400 text-xs"
>市场价{{
record.salePrice ? `${record.salePrice}` : '-'
}}</span
>
<span class="text-gray-400 text-xs"
>会员价{{
record.dealerPrice ? `${record.dealerPrice}` : '-'
}}</span
>
</div>
</template>
<template v-if="column.key === 'recommend'">
<a-space @click.stop="onRecommend(record)">
<span
@@ -222,35 +244,10 @@
key: 'name',
width: 300
},
{
title: '编号',
dataIndex: 'code',
key: 'code',
align: 'center',
},
{
title: '市场价',
dataIndex: 'salePrice',
key: 'salePrice',
align: 'center',
width: 110,
customRender: ({ text }) => (text ? `${text}` : '-')
},
{
title: '价格',
dataIndex: 'price',
key: 'price',
align: 'center',
width: 110,
customRender: ({ text }) => `${text}`
},
{
title: '会员价',
dataIndex: 'dealerPrice',
key: 'dealerPrice',
align: 'center',
width: 110,
customRender: ({ text }) => (text ? `${text}` : '-')
key: 'priceGroup',
dataIndex: 'priceGroup'
},
{
title: '销量',
@@ -617,11 +614,11 @@
return {
// 行点击事件
onClick: () => {
openEdit(record);
// openEdit(record);
},
// 行双击事件
onDblclick: () => {
// openEdit(record);
openEdit(record);
}
};
};