feat: 完成 SN 溯源、销售管理和维修记录。

This commit is contained in:
c
2026-03-12 16:26:59 +08:00
parent d22857b890
commit e7ac6b5f62
8 changed files with 556 additions and 68 deletions

View File

@@ -7,6 +7,7 @@ import { useStatus } from "@/common/languages/mapping/base-info-mapping";
const props = defineProps({
tableEl: ref,
statusLabelMapping: Function,
tagTypeMapping: Function,
statusParamName: {
type: String,
default: "status",
@@ -37,14 +38,26 @@ const getLabel = (code: number | null) => {
if (props.statusLabelMapping === undefined) return getCommonStatusLabel(code);
return props.statusLabelMapping(code);
};
const getTagType = (code: number | null): string => {
if (props.tagTypeMapping !== undefined) {
return props.tagTypeMapping(code);
}
// 默认逻辑switchOnValue 为 success其他为 info
return code === props.switchOnValue ? "success" : "info";
};
</script>
<template>
<el-table-column :label="$t('_prop.common.status')" :prop="statusParamName">
<template #default="scope">
<!-- 没有权限按钮时显示带框标签 -->
<span v-if="buttonList.length === 0">
{{ getLabel(scope.row[statusParamName]) }}
<el-tag :type="getTagType(scope.row[statusParamName])" size="small">
{{ getLabel(scope.row[statusParamName]) }}
</el-tag>
</span>
<template v-for="button in buttonList" :key="button.buttonName">
<!-- 有权限按钮时显示开关或标签 -->
<template v-else v-for="button in buttonList" :key="button.buttonName">
<StatusSwitch
v-model="scope.row[statusParamName]"
@change="val => change(val, scope.row)"
@@ -54,6 +67,21 @@ const getLabel = (code: number | null) => {
"
/>
</template>
<!-- 有权限但没有匹配到开关时,显示带框标签 -->
<el-tag
v-if="
buttonList.length > 0 &&
!buttonList.some(
button =>
(button.eventName === 'enable' && scope.row[statusParamName] === switchOffValue) ||
(button.eventName === 'disable' && scope.row[statusParamName] === switchOnValue)
)
"
:type="getTagType(scope.row[statusParamName])"
size="small"
>
{{ getLabel(scope.row[statusParamName]) }}
</el-tag>
</template>
</el-table-column>
</template>