Files
lilishop-ui/buyer/src/components/card/index.vue
lifenlong 88fc1b0b2a refactor: 四端完成 Options API → script setup + vuex → pinia 迁移
- buyer(95) / seller(169) / im(53) / manager(280) 共 597 个组件全部从 Options API 转换为 <script setup>
- 四端 vuex 全部移除,状态管理统一迁移至 pinia 4(stores/ 目录)
- util.js 等基础设施去除 vm 首参依赖;全局属性($Message/$filters 等)在 script 内改为具名导入
- 被外部 ref 访问的公共组件均已补齐 defineExpose(清单见各端 MIGRATION-VUE3.md)
- 各端 eslint 启用 vue/component-api-style 防止新代码回退 Options API
- 四端 yarn build 全部通过;迁移约定与注意事项已更新至各端 MIGRATION-VUE3.md
2026-10-13 07:06:59 +08:00

160 lines
2.6 KiB
Vue

<template>
<el-card class="_Card" shadow="never">
<template #header>
<div class="card-header">
<div class="cardTitle">
<span :style="{ fontSize: `${_Size}px` }">{{ _Title }}</span>
<div v-if="_Tabs" class="cardTabs">
<div
@click="tabsChange(index)"
:class="{ active: isActive == index }"
class="cardTabsItem"
:style="{ fontSize: `${_Size - 2}px` }"
v-for="(item, index) in _Tabs"
:key="index"
>
{{ item }}
</div>
</div>
</div>
<div class="cardExtra" v-if="_More" @click="callBack()">
{{ _More }}
</div>
</div>
</template>
<slot />
</el-card>
</template>
<script setup>
import { ref, watch } from "vue";
import { useRouter } from "vue-router";
defineOptions({ name: "index" });
const props = defineProps({
_Tabs: {
type: null,
default: "",
},
_Title: {
type: null,
default: "卡片头部",
},
_More: {
type: null,
default: false,
},
_Size: {
type: Number,
default: 16,
},
_Src: {
type: null,
default: null,
},
_ActiveTab: {
type: Number,
default: 0,
},
});
const emit = defineEmits(["_Change"]);
const router = useRouter();
const isActive = ref(props._ActiveTab);
watch(
() => props._ActiveTab,
(val) => {
isActive.value = val;
}
);
function callBack() {
if (props._Src) {
router.push({ path: props._Src });
}
}
function tabsChange(index) {
isActive.value = index;
emit("_Change", index);
}
</script>
<style scoped lang="scss">
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
}
.cardTitle {
display: flex;
cursor: pointer;
}
.active {
color: $theme_color;
position: relative;
&::before {
content: "";
position: absolute;
width: 100%;
height: 3px;
bottom: 0;
left: 0;
background: $theme_color;
}
}
.cardTabs {
display: flex;
padding: 0 12px;
> .cardTabsItem {
padding: 0 12px;
}
> .cardTabsItem:hover {
color: $theme_color;
}
}
:deep(._Card) {
margin-bottom: 20px;
@include white_background_color();
}
:deep(._Card .el-card__header) {
position: relative;
padding: 0 14px;
height: 50px;
line-height: 50px;
&::before {
content: "";
width: 3px;
height: 50%;
top: 25%;
background: $theme_color;
position: absolute;
left: 0;
}
}
.cardExtra {
color: $theme_color;
cursor: pointer;
}
:deep(._Card .el-card__body) {
padding: 0 !important;
min-height: 0;
}
:deep(._Card .el-card__body:empty) {
display: none;
}
</style>