style(frontend): 商品 / 组合商品的操作记录改为点击行下方展开

与店铺商品页统一风格:
- 去掉操作列的「日志」按钮(操作列宽度 180 → 140)
- 点击行在表格下方(分页之后)展开操作记录面板,再次点击同一行收起
- 表格保持内部滚动,展开面板后表格自动让出高度
- 点击行内「编辑 / 删除」按钮不会误触发展开
- 移除原日志弹窗与 log-dialog-body 样式,补充 log-wrap / log-head / log-body 样式

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-11-03 17:20:41 +08:00
parent 95c268836e
commit d2724643e7
2 changed files with 114 additions and 42 deletions

View File

@ -221,19 +221,30 @@ async function handleDelete(row: ComboProductItem) {
}
}
/* -------------------- 操作记录 -------------------- */
const logVisible = ref(false)
/* -------------------- 操作记录(点击行后在下方展开,与店铺商品一致) -------------------- */
const logRow = ref<ComboProductItem | null>(null)
const logPanelHeight = ref(240)
function openLog(row: ComboProductItem) {
function onRowClick(row: ComboProductItem, _column?: unknown, event?: Event) {
// 点行内按钮(编辑/删除)时不展开操作记录
const target = event && (event.target as HTMLElement | null)
if (target && target.closest && target.closest('button')) return
// 再次点击同一行则收起
if (logRow.value && logRow.value.id === row.id) {
closeLog()
return
}
logRow.value = row
logVisible.value = true
}
const logTitle = computed(() => {
function closeLog() {
logRow.value = null
}
const logTargetName = computed(() => {
const row = logRow.value
if (!row) return '操作记录'
return `操作记录:${row.name || ''}(${row.code || ''})`
return `${row.name || ''}(${row.code || ''})`
})
onMounted(fetchList)
@ -272,8 +283,8 @@ onMounted(fetchList)
</el-form-item>
</el-form>
<div class="list-table-wrap">
<DataTable :loading="loading" :data="list" height="100%">
<div class="list-table-wrap" :class="{ 'list-table-wrap--with-log': !!logRow }">
<DataTable :loading="loading" :data="list" height="100%" highlight-current-row @row-click="onRowClick">
<el-table-column prop="code" label="组合编码" width="130" />
<el-table-column prop="name" label="组合名称" min-width="150" />
<el-table-column label="组合售价" width="100" align="right">
@ -289,10 +300,9 @@ onMounted(fetchList)
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="180" fixed="right">
<el-table-column label="操作" width="140" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
<el-button link type="info" @click="openLog(row)">日志</el-button>
<el-button link type="danger" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
@ -308,21 +318,21 @@ onMounted(fetchList)
@size-change="handleSizeChange"
/>
<!-- 操作记录:新增 / 修改(含子商品构成)/ 删除留痕 -->
<el-dialog v-model="logVisible" :title="logTitle" width="min(900px, 94vw)" top="6vh" destroy-on-close>
<div class="log-dialog-body">
<!-- 操作记录:点击组合商品行后在下方展开(新增 / 修改含构成 / 删除留痕) -->
<div v-if="logRow" class="log-wrap" :style="{ height: `${logPanelHeight}px` }">
<div class="log-head">
<span class="log-name">{{ logTargetName }}</span>
<el-button link size="small" class="log-close" @click="closeLog">收起</el-button>
</div>
<div class="log-body">
<OperationLogPanel
v-if="logRow"
:target-type="'combo_product'"
:target-id="logRow.id"
:table-height="360"
:table-height="'100%'"
hide-header
/>
</div>
<template #footer>
<el-button @click="logVisible = false">关闭</el-button>
</template>
</el-dialog>
</div>
<el-drawer
v-model="drawerVisible"
@ -457,10 +467,36 @@ onMounted(fetchList)
justify-content: space-between;
font-weight: 600;
}
.log-dialog-body {
height: 420px;
/* 底部展开操作记录后,表格让出一部分高度(表格内部仍可滚动) */
.log-wrap {
flex: 0 0 auto;
display: flex;
flex-direction: column;
min-height: 0;
margin-top: 8px;
padding-top: 8px;
border-top: 1px solid var(--el-border-color-lighter);
}
.log-head {
flex: 0 0 auto;
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
}
.log-name {
font-size: 12px;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.log-close {
margin-left: auto;
}
.log-body {
flex: 1 1 auto;
min-height: 0;
}
.search-bar {
margin-bottom: 16px;

View File

@ -359,19 +359,30 @@ async function handleDelete(row: ProductItem) {
}
}
/* -------------------- 操作记录 -------------------- */
const logVisible = ref(false)
/* -------------------- 操作记录(点击行后在下方展开,与店铺商品一致) -------------------- */
const logRow = ref<ProductItem | null>(null)
const logPanelHeight = ref(240)
function openLog(row: ProductItem) {
function onRowClick(row: ProductItem, _column?: unknown, event?: Event) {
// 点行内按钮(编辑/删除)时不展开操作记录
const target = event && (event.target as HTMLElement | null)
if (target && target.closest && target.closest('button')) return
// 再次点击同一行则收起
if (logRow.value && logRow.value.id === row.id) {
closeLog()
return
}
logRow.value = row
logVisible.value = true
}
const logTitle = computed(() => {
function closeLog() {
logRow.value = null
}
const logTargetName = computed(() => {
const row = logRow.value
if (!row) return '操作记录'
return `操作记录:${row.item_name || ''}(${row.item_code || ''})`
return `${row.item_name || ''}(${row.item_code || ''})`
})
/* -------------------- 批量导入 -------------------- */
@ -513,8 +524,8 @@ onMounted(async () => {
</el-form-item>
</el-form>
<div class="list-table-wrap">
<DataTable :loading="loading" :data="list" height="100%">
<div class="list-table-wrap" :class="{ 'list-table-wrap--with-log': !!logRow }">
<DataTable :loading="loading" :data="list" height="100%" highlight-current-row @row-click="onRowClick">
<el-table-column prop="item_code" label="商品编码" width="130" />
<el-table-column prop="goods_code" label="货物编码" width="120" />
<el-table-column prop="barcode" label="条码" width="120" />
@ -561,10 +572,9 @@ onMounted(async () => {
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="180" fixed="right">
<el-table-column label="操作" width="140" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
<el-button link type="info" @click="openLog(row)">日志</el-button>
<el-button link type="danger" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
@ -580,21 +590,21 @@ onMounted(async () => {
@size-change="handleSizeChange"
/>
<!-- 操作记录:新增 / 修改 / 删除留痕 -->
<el-dialog v-model="logVisible" :title="logTitle" width="min(900px, 94vw)" top="6vh" destroy-on-close>
<div class="log-dialog-body">
<!-- 操作记录:点击商品行后在下方展开(新增 / 修改 / 删除留痕) -->
<div v-if="logRow" class="log-wrap" :style="{ height: `${logPanelHeight}px` }">
<div class="log-head">
<span class="log-name">{{ logTargetName }}</span>
<el-button link size="small" class="log-close" @click="closeLog">收起</el-button>
</div>
<div class="log-body">
<OperationLogPanel
v-if="logRow"
:target-type="'product'"
:target-id="logRow.id"
:table-height="360"
:table-height="'100%'"
hide-header
/>
</div>
<template #footer>
<el-button @click="logVisible = false">关闭</el-button>
</template>
</el-dialog>
</div>
<!-- 批量导入:上传 xlsx,按商品编码新增/更新 -->
<el-dialog v-model="importVisible" title="批量导入商品" width="min(720px, 94vw)" top="8vh" destroy-on-close>
@ -856,10 +866,36 @@ onMounted(async () => {
justify-content: space-between;
font-weight: 600;
}
.log-dialog-body {
height: 420px;
/* 底部展开操作记录后,表格让出一部分高度(表格内部仍可滚动) */
.log-wrap {
flex: 0 0 auto;
display: flex;
flex-direction: column;
min-height: 0;
margin-top: 8px;
padding-top: 8px;
border-top: 1px solid var(--el-border-color-lighter);
}
.log-head {
flex: 0 0 auto;
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
}
.log-name {
font-size: 12px;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.log-close {
margin-left: auto;
}
.log-body {
flex: 1 1 auto;
min-height: 0;
}
.import-body {
display: flex;