style(product): ProductCard升级为SCSS嵌套写法,优化卡片渐变背景与阴影

This commit is contained in:
小蟑螂
2026-04-28 23:55:38 +08:00
parent 57fe400dee
commit 16039f18a0
2 changed files with 411 additions and 446 deletions
@@ -717,122 +717,128 @@ const saveEdit = async () => {
</div>
</SyncModal>
</template>
<style scoped>
<style scoped lang="scss">
.management-card {
border-radius: 12px;
overflow: hidden;
border: 1px solid #f0f0f0;
background: #ffffff;
box-shadow: 0 8px 24px rgb(0 0 0 / 5%);
border: 1px solid #d7e1ee;
background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
box-shadow:
0 14px 34px rgb(15 23 42 / 9%),
0 2px 10px rgb(15 23 42 / 5%);
transition: all 0.2s ease;
}
.management-card:hover {
transform: translateY(-1px);
box-shadow: 0 10px 28px rgb(0 0 0 / 7%);
}
&:hover {
transform: translateY(-2px);
border-color: #b8c8de;
box-shadow:
0 20px 38px rgb(15 23 42 / 14%),
0 6px 14px rgb(15 23 42 / 9%);
}
.management-card.editing {
border-color: #5b6df5;
box-shadow: 0 0 0 2px rgba(91, 109, 245, 0.12), 0 10px 28px rgb(0 0 0 / 7%);
}
&.editing {
border-color: #5b6df5;
box-shadow: 0 0 0 2px rgba(91, 109, 245, 0.12), 0 10px 28px rgb(0 0 0 / 7%);
}
.card-top {
display: flex;
gap: 24px;
padding: 28px;
border-bottom: 1px solid #f9f9f9;
}
.card-top {
display: flex;
gap: 24px;
padding: 28px;
border-bottom: 1px solid #dde6f2;
background: linear-gradient(180deg, rgb(237 245 255 / 95%) 0%, #ffffff 100%);
}
.info-main {
flex: 1;
min-width: 0;
}
.info-main {
flex: 1;
min-width: 0;
}
.field-row {
display: flex;
align-items: flex-start;
gap: 8px;
margin-bottom: 12px;
min-height: 32px;
}
.field-row {
display: flex;
align-items: flex-start;
gap: 8px;
margin-bottom: 12px;
min-height: 32px;
}
.field-label {
font-size: 13px;
color: #8c8c8c;
font-weight: 400;
width: 70px;
flex-shrink: 0;
padding-top: 4px;
}
.field-label {
font-size: 13px;
color: #8c8c8c;
font-weight: 400;
width: 70px;
flex-shrink: 0;
padding-top: 4px;
}
.img-preview {
width: 140px;
height: 140px;
flex-shrink: 0;
border: 1px solid #eeeeee;
border-radius: 6px;
overflow: hidden;
background: #fbfbfb;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.img-preview {
width: 140px;
height: 140px;
flex-shrink: 0;
border: 1px solid #eeeeee;
border-radius: 6px;
overflow: hidden;
background: #fbfbfb;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.editing-img.img-preview {
cursor: pointer;
border-color: rgba(91, 109, 245, 0.4);
border-style: dashed;
transition: all 0.15s;
}
.editing-img.img-preview {
cursor: pointer;
border-color: rgba(91, 109, 245, 0.4);
border-style: dashed;
transition: all 0.15s;
.editing-img.img-preview:hover {
border-color: #5b6df5;
background: rgba(91, 109, 245, 0.04);
}
&:hover {
border-color: #5b6df5;
background: rgba(91, 109, 245, 0.04);
}
}
.image-upload-area {
width: 100%;
height: 100%;
position: relative;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.image-upload-area {
width: 100%;
height: 100%;
position: relative;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
.image-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #ffffff;
opacity: 0;
transition: opacity 0.2s;
border-radius: 5px;
}
&:hover .image-overlay {
opacity: 1;
}
}
.image-upload-area:hover .image-overlay {
opacity: 1;
}
.image-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #ffffff;
opacity: 0;
transition: opacity 0.2s;
border-radius: 5px;
}
.img-reset-btn {
position: absolute;
bottom: -28px;
left: 0;
font-size: 11px;
height: 22px;
padding: 0 8px;
border-color: #d0d8e2;
color: #64748b;
.img-reset-btn {
position: absolute;
bottom: -28px;
left: 0;
font-size: 11px;
height: 22px;
padding: 0 8px;
border-color: #d0d8e2;
color: #64748b;
}
}
.product-image {
@@ -1059,7 +1065,8 @@ const saveEdit = async () => {
}
.meta-box {
background: #f8f9fb;
background: linear-gradient(180deg, #f8fbff 0%, #f2f7ff 100%);
border: 1px solid #e4ecf7;
border-radius: 6px;
padding: 8px 12px;
display: flex;
@@ -1087,6 +1094,7 @@ const saveEdit = async () => {
.specs-wrapper {
padding: 0 28px 24px;
min-width: 640px;
background: #fff;
}
.specs-header-row {
@@ -1114,16 +1122,18 @@ const saveEdit = async () => {
}
.table-container {
border: 1px solid #f0f0f0;
border: 1px solid #e2eaf5;
border-radius: 6px;
overflow-x: auto;
overflow-y: hidden;
background: #fcfeff;
}
.spec-head {
background: #fafafa;
color: #8c8c8c;
background: linear-gradient(180deg, #f5f9ff 0%, #edf4ff 100%);
color: #6b7280;
font-weight: 600;
border-bottom: 1px solid #e2eaf5;
}
.spec-row {
@@ -1244,8 +1254,8 @@ const saveEdit = async () => {
justify-content: flex-start;
gap: 12px;
padding: 12px 28px;
border-top: 1px solid #f0f0f0;
background: #fcfcfc;
border-top: 1px solid #dde6f2;
background: linear-gradient(180deg, #ffffff 0%, #eef5ff 100%);
}
.btn {
@@ -1436,346 +1446,300 @@ const saveEdit = async () => {
</style>
<!-- 深色:无 scoped,避免 Ant Card 根节点吃不到样式;颜色与 @vben design-tokens/dark.css 的 CSS 变量一致 -->
<style>
html.dark .management-card.ant-card {
background-color: hsl(var(--card)) !important;
border-color: hsl(var(--border)) !important;
box-shadow: none;
}
html.dark .management-card.ant-card .ant-card-body {
background-color: transparent !important;
}
html.dark .management-card.editing {
border-color: hsl(var(--primary));
box-shadow:
0 0 0 2px hsl(var(--primary) / 20%),
0 10px 28px hsl(var(--overlay));
}
html.dark .management-card .card-top {
background: transparent;
border-bottom-color: hsl(var(--border));
}
html.dark .management-card .field-label {
color: hsl(var(--muted-foreground));
}
html.dark .management-card .img-preview {
background: hsl(var(--muted));
border-color: hsl(var(--border));
}
html.dark .management-card .editing-img.img-preview:hover {
border-color: hsl(var(--primary));
background: hsl(var(--accent));
}
html.dark .management-card .specs-wrapper {
background: transparent;
}
html.dark .management-card .specs-header-row .ant-btn-dashed {
background: hsl(var(--secondary)) !important;
border-color: hsl(var(--primary) / 45%) !important;
color: hsl(var(--primary)) !important;
}
html.dark .management-card .specs-header-row .ant-btn-dashed:hover {
background: hsl(var(--accent)) !important;
border-color: hsl(var(--primary)) !important;
color: hsl(var(--primary-foreground)) !important;
}
html.dark .management-card .cost-number-input {
border-color: hsl(var(--primary) / 40%) !important;
background: hsl(var(--input-background)) !important;
color: hsl(var(--foreground)) !important;
}
html.dark .management-card .cost-number-input .ant-input-number-input {
background: transparent !important;
color: inherit !important;
}
html.dark .management-card .cost-number-input:hover {
border-color: hsl(var(--primary)) !important;
background: hsl(var(--accent)) !important;
}
html.dark .management-card .cost-number-input:focus,
html.dark .management-card .cost-number-input.ant-input-number-focused {
border-color: hsl(var(--primary)) !important;
background: hsl(var(--accent)) !important;
box-shadow: 0 0 0 2px hsl(var(--primary) / 22%) !important;
}
html.dark .management-card .cost-number-input .ant-input-number-handler-wrap {
background: hsl(var(--muted));
border-inline-start-color: hsl(var(--border));
}
html.dark .management-card .cost-number-input .ant-input-number-handler {
color: hsl(var(--muted-foreground));
}
html.dark .management-card .spec-row {
background: hsl(var(--accent-lighter));
border-bottom-color: hsl(var(--border));
}
html.dark .management-card .card-footer {
background: hsl(var(--accent-lighter));
border-top-color: hsl(var(--border));
}
html.dark .management-card .spec-head {
background: hsl(var(--accent)) !important;
color: hsl(var(--muted-foreground));
}
html.dark .management-card .spec-head .cell-head {
color: hsl(var(--muted-foreground));
}
html.dark .management-card .table-container {
background: hsl(var(--accent-lighter));
border-color: hsl(var(--border));
}
html.dark .management-card .editing-row {
background: hsl(var(--primary) / 8%) !important;
}
html.dark .management-card .btn-edit {
background: hsl(var(--secondary)) !important;
border-color: hsl(var(--primary)) !important;
color: hsl(var(--primary)) !important;
}
html.dark .management-card .btn-edit:hover {
background: hsl(var(--accent-hover)) !important;
color: hsl(var(--primary-foreground)) !important;
}
html.dark .management-card .btn-stats {
background: hsl(var(--secondary)) !important;
border-color: hsl(var(--success)) !important;
color: hsl(var(--success)) !important;
}
html.dark .management-card .btn-stats:hover {
background: hsl(var(--accent)) !important;
color: hsl(var(--success-foreground)) !important;
}
html.dark .management-card .btn-cancel {
background: hsl(var(--secondary)) !important;
border-color: hsl(var(--border)) !important;
color: hsl(var(--muted-foreground)) !important;
}
html.dark .management-card .btn-delete {
background: hsl(var(--secondary)) !important;
border-color: hsl(var(--destructive)) !important;
color: hsl(var(--destructive)) !important;
}
html.dark .management-card .btn-delete:hover {
background: hsl(var(--destructive) / 18%) !important;
}
html.dark .management-card .btn-save.ant-btn-default:not(:disabled) {
background: hsl(var(--secondary)) !important;
border-color: hsl(var(--border)) !important;
color: hsl(var(--foreground)) !important;
}
html.dark .management-card .btn-save.ant-btn-default:hover:not(:disabled) {
border-color: hsl(var(--primary)) !important;
color: hsl(var(--primary)) !important;
}
html.dark .management-card .field-text--title,
html.dark .management-card .field-text,
html.dark .management-card .value,
html.dark .management-card .cost-text {
color: hsl(var(--foreground));
}
html.dark .management-card .meta-box {
background: hsl(var(--muted));
border: 1px solid hsl(var(--border));
}
html.dark .management-card .more-tip {
background: hsl(var(--accent-lighter));
border-top: 1px dashed hsl(var(--border));
}
html.dark .management-card .meta-box,
html.dark .management-card .table-container,
html.dark .management-card .spec-row,
html.dark .management-card .card-footer {
border-color: hsl(var(--border));
}
html.dark .management-card .op-col {
background: hsl(var(--accent-lighter));
}
html.dark .management-card .label,
html.dark .management-card .more-tip,
html.dark .management-card .empty-text,
html.dark .management-card .no-image {
color: hsl(var(--muted-foreground));
}
html.dark .management-card .no-image-icon {
color: hsl(var(--muted-foreground));
opacity: 0.85;
}
html.dark .management-card .code-tag {
background: hsl(var(--secondary));
color: hsl(var(--primary));
}
html.dark .management-card .specs-header {
color: hsl(var(--foreground));
}
html.dark .management-card .spec-row.editing-row {
background: hsl(var(--primary) / 8%);
}
html.dark .management-card .spec-row.editing-row:hover {
background: hsl(var(--primary) / 12%);
}
html.dark .management-card .field-input {
border-color: hsl(var(--primary) / 40%);
background: hsl(var(--input-background));
color: hsl(var(--foreground));
}
html.dark .management-card .field-input:hover {
border-color: hsl(var(--primary));
background: hsl(var(--accent));
}
html.dark .management-card .field-input:focus,
html.dark .management-card .field-input.ant-input-focused {
border-color: hsl(var(--primary));
background: hsl(var(--accent));
box-shadow: 0 0 0 2px hsl(var(--primary) / 20%);
}
html.dark .management-card .cost-input-wrap {
border-color: hsl(var(--primary) / 40%);
background: hsl(var(--input-background));
}
html.dark .management-card .cost-input-wrap:hover {
border-color: hsl(var(--primary));
background: hsl(var(--accent));
}
html.dark .management-card .cost-input-wrap:focus-within {
border-color: hsl(var(--primary));
background: hsl(var(--accent));
box-shadow: 0 0 0 2px hsl(var(--primary) / 20%);
}
html.dark .management-card .cost-prefix {
color: hsl(var(--muted-foreground));
}
html.dark .management-card .field-textarea {
border-color: hsl(var(--primary) / 40%);
background: hsl(var(--input-background));
color: hsl(var(--foreground));
}
html.dark .management-card .field-textarea:hover {
border-color: hsl(var(--primary));
background: hsl(var(--accent));
}
html.dark .management-card .field-textarea:focus,
html.dark .management-card .field-textarea.ant-input-focused {
border-color: hsl(var(--primary));
background: hsl(var(--accent));
box-shadow: 0 0 0 2px hsl(var(--primary) / 20%);
}
html.dark .management-card .field-tree-select .ant-select-selector {
border-color: hsl(var(--primary) / 40%) !important;
background: hsl(var(--input-background)) !important;
color: hsl(var(--foreground)) !important;
}
html.dark .management-card .field-tree-select:hover .ant-select-selector {
border-color: hsl(var(--primary)) !important;
background: hsl(var(--accent)) !important;
}
html.dark .management-card .field-tree-select.ant-select-focused .ant-select-selector {
border-color: hsl(var(--primary)) !important;
background: hsl(var(--accent)) !important;
box-shadow: 0 0 0 2px hsl(var(--primary) / 20%) !important;
}
/* 成本同步弹窗(Teleport 到 body,不在 .management-card 内) */
html.dark .product-cost-sync .section-label {
color: hsl(var(--muted-foreground));
}
html.dark .product-cost-sync .sync-alert {
background: hsl(var(--warning) / 12%);
border-color: hsl(var(--warning) / 35%);
color: hsl(var(--warning));
}
html.dark .product-cost-sync .spec-item-card {
border-color: hsl(var(--border));
background: hsl(var(--muted));
}
html.dark .product-cost-sync .spec-item-card:hover {
border-color: hsl(var(--primary) / 50%);
background: hsl(var(--accent));
}
html.dark .product-cost-sync .spec-item-card.active {
border-color: hsl(var(--primary));
background: hsl(var(--primary) / 10%);
}
html.dark .product-cost-sync .custom-checkbox {
background: hsl(var(--muted));
border-color: hsl(var(--border));
}
html.dark .product-cost-sync .spec-title {
color: hsl(var(--foreground));
}
html.dark .product-cost-sync .spec-code {
color: hsl(var(--muted-foreground));
}
html.dark .product-cost-sync .cost-snapshot {
border-left-color: hsl(var(--border));
}
html.dark .product-cost-sync .cost-tag {
color: hsl(var(--muted-foreground));
}
html.dark .product-cost-sync .cost-tag span:last-child {
color: hsl(var(--foreground));
<style lang="scss">
$card-text: hsl(var(--foreground));
$muted-text: hsl(var(--muted-foreground));
$card-bg: hsl(var(--card));
$accent-bg: hsl(var(--accent));
$accent-light-bg: hsl(var(--accent-lighter));
$border-base: hsl(var(--border));
$primary: hsl(var(--primary));
$primary-soft: hsl(var(--primary) / 40%);
$input-bg: hsl(var(--input-background));
$secondary-bg: hsl(var(--secondary));
@mixin interactive-field($important: false) {
$flag: if($important, ' !important', '');
border-color: #{$primary-soft}#{$flag};
background: #{$input-bg}#{$flag};
color: #{$card-text}#{$flag};
&:hover {
border-color: #{$primary}#{$flag};
background: #{$accent-bg}#{$flag};
}
&:focus,
&.ant-input-focused {
border-color: #{$primary}#{$flag};
background: #{$accent-bg}#{$flag};
box-shadow: 0 0 0 2px hsl(var(--primary) / 20%)#{$flag};
}
}
@mixin outline-btn($border, $text, $hover-bg: $accent-bg, $hover-text: null) {
background: #{$secondary-bg} !important;
border-color: #{$border} !important;
color: #{$text} !important;
&:hover {
background: #{$hover-bg} !important;
@if $hover-text != null {
color: #{$hover-text} !important;
}
}
}
html.dark {
.management-card {
&.ant-card {
background: linear-gradient(180deg, #{$card-bg} 0%, hsl(var(--card) / 92%) 100%) !important;
border-color: hsl(var(--primary) / 40%) !important;
box-shadow:
0 18px 32px hsl(220deg 40% 2% / 52%),
0 4px 10px hsl(220deg 40% 2% / 38%) !important;
.ant-card-body {
background-color: transparent !important;
}
}
&.editing {
border-color: $primary;
box-shadow: 0 0 0 2px hsl(var(--primary) / 20%), 0 10px 28px hsl(var(--overlay));
}
.card-top {
background: linear-gradient(180deg, hsl(var(--accent-lighter) / 80%) 0%, #{$card-bg} 100%);
border-bottom-color: hsl(var(--primary) / 28%);
}
.field-label,
.label,
.more-tip,
.empty-text,
.no-image,
.cost-prefix {
color: $muted-text;
}
.img-preview {
background: hsl(var(--muted));
border-color: $border-base;
}
.editing-img.img-preview:hover {
border-color: $primary;
background: $accent-bg;
}
.specs-wrapper {
background: $card-bg;
}
.specs-header-row .ant-btn-dashed {
@include outline-btn($primary-soft, $primary, $accent-bg, hsl(var(--primary-foreground)));
}
.spec-row {
background: $accent-light-bg;
border-bottom-color: $border-base;
&.editing-row {
background: hsl(var(--primary) / 8%);
&:hover {
background: hsl(var(--primary) / 12%);
}
}
}
.card-footer {
background: linear-gradient(180deg, #{$card-bg} 0%, hsl(var(--accent-lighter) / 85%) 100%);
border-top-color: hsl(var(--primary) / 28%);
}
.spec-head {
background: $accent-bg !important;
color: $muted-text;
.cell-head {
color: $muted-text;
}
}
.table-container {
background: $accent-light-bg;
border-color: hsl(var(--primary) / 22%);
}
.btn-edit {
@include outline-btn($primary, $primary, hsl(var(--accent-hover)), hsl(var(--primary-foreground)));
}
.btn-stats {
@include outline-btn(hsl(var(--success)), hsl(var(--success)), $accent-bg, hsl(var(--success-foreground)));
}
.btn-cancel {
@include outline-btn($border-base, $muted-text, $secondary-bg);
}
.btn-delete {
@include outline-btn(hsl(var(--destructive)), hsl(var(--destructive)), hsl(var(--destructive) / 18%));
}
.btn-save.ant-btn-default {
&:not(:disabled) {
background: $secondary-bg !important;
border-color: $border-base !important;
color: $card-text !important;
}
&:hover:not(:disabled) {
border-color: $primary !important;
color: $primary !important;
}
}
.field-text--title,
.field-text,
.value,
.cost-text {
color: $card-text;
}
.meta-box {
background: linear-gradient(180deg, hsl(var(--muted) / 92%) 0%, hsl(var(--accent-lighter) / 92%) 100%);
border: 1px solid hsl(var(--primary) / 26%);
}
.more-tip {
background: $accent-light-bg;
border-top: 1px dashed $border-base;
}
.meta-box,
.table-container,
.spec-row,
.card-footer {
border-color: $border-base;
}
.op-col {
background: $accent-light-bg;
}
.no-image-icon {
color: $muted-text;
opacity: 0.85;
}
.code-tag {
background: $secondary-bg;
color: $primary;
}
.specs-header {
color: $card-text;
}
.field-input,
.field-textarea {
@include interactive-field(false);
}
.cost-input-wrap {
@include interactive-field(false);
&:focus-within {
border-color: $primary;
background: $accent-bg;
box-shadow: 0 0 0 2px hsl(var(--primary) / 20%);
}
}
.field-tree-select {
.ant-select-selector {
@include interactive-field(true);
}
&:hover .ant-select-selector {
border-color: $primary !important;
background: $accent-bg !important;
}
&.ant-select-focused .ant-select-selector {
border-color: $primary !important;
background: $accent-bg !important;
box-shadow: 0 0 0 2px hsl(var(--primary) / 20%) !important;
}
}
.cost-number-input {
@include interactive-field(true);
.ant-input-number-input {
background: transparent !important;
color: inherit !important;
}
.ant-input-number-handler-wrap {
background: hsl(var(--muted));
border-inline-start-color: $border-base;
}
.ant-input-number-handler {
color: $muted-text;
}
}
}
/* 成本同步弹窗(Teleport 到 body,不在 .management-card 内) */
.product-cost-sync {
.section-label,
.spec-code,
.cost-tag {
color: $muted-text;
}
.sync-alert {
background: hsl(var(--warning) / 12%);
border-color: hsl(var(--warning) / 35%);
color: hsl(var(--warning));
}
.spec-item-card {
border-color: $border-base;
background: hsl(var(--muted));
&:hover {
border-color: hsl(var(--primary) / 50%);
background: $accent-bg;
}
&.active {
border-color: $primary;
background: hsl(var(--primary) / 10%);
}
}
.custom-checkbox {
background: hsl(var(--muted));
border-color: $border-base;
}
.spec-title {
color: $card-text;
}
.cost-snapshot {
border-left-color: $border-base;
}
.cost-tag span:last-child {
color: $card-text;
}
}
}
</style>
@@ -300,6 +300,7 @@ onUnmounted(() => {
ref="waterfallRef"
:list="productList"
row-key="id"
:horizontalOrder="true"
:width="700"
:breakpoints="{
2700: { rowPerView: 3 },