feat: 完成 SN 溯源、销售管理和维修记录。
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user