优化前端字典预览组件

This commit is contained in:
zhoumingfa 2025-03-28 21:21:02 +08:00
parent b72f58a0bb
commit 45b5ba6795
6 changed files with 18 additions and 25 deletions

View File

@ -1,11 +1,6 @@
<template> <template>
<div> <div>
<template v-for="(item, index) in options"> <span>{{ dictValueName }}</span>
<template v-if="values.includes(item.valueCode)">
{{ item.valueName }}
<span> </span>
</template>
</template>
</div> </div>
</template> </template>
@ -21,8 +16,11 @@
// //
value: [Number, String, Array], value: [Number, String, Array],
}); });
const values = computed(() => { const dictValueName = computed(() => {
if (props.value === null || typeof props.value === 'undefined' || props.value === '') return []; if (props.value === null || typeof props.value === 'undefined' || props.value === '') return '';
return Array.isArray(props.value) ? props.value.map((item) => item.valueCode) : props.value.split(','); const valueCodeList = Array.isArray(props.value) ? props.value.map((item) => item.valueCode) : props.value.split(',');
const valueNameList = props.options.filter((item) => valueCodeList.includes(item.valueCode)).map((item) => item.valueName);
return valueNameList.join('');
}); });
</script> </script>

View File

@ -120,7 +120,7 @@
{{ text }} {{ text }}
</template> </template>
<template v-if="column.dataIndex === 'place'"> <template v-if="column.dataIndex === 'place'">
<DictPreview :options="descList.GOODS_PLACE" :value="text" /> <DictPreview :options="descList['GOODS_PLACE']" :value="text" />
</template> </template>
<template v-if="column.dataIndex === 'remark'"> <template v-if="column.dataIndex === 'remark'">
<span>{{ text ? text : '' }}</span> <span>{{ text ? text : '' }}</span>
@ -199,7 +199,6 @@
import { smartSentry } from '/@/lib/smart-sentry'; import { smartSentry } from '/@/lib/smart-sentry';
import TableOperator from '/@/components/support/table-operator/index.vue'; import TableOperator from '/@/components/support/table-operator/index.vue';
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const'; import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
import { GOODS_STATUS_ENUM } from '/@/constants/business/erp/goods-const';
import DictSelect from '/@/components/support/dict-select/index.vue'; import DictSelect from '/@/components/support/dict-select/index.vue';
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue'; import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
import _ from 'lodash'; import _ from 'lodash';
@ -236,7 +235,6 @@
title: '商品状态', title: '商品状态',
dataIndex: 'goodsStatus', dataIndex: 'goodsStatus',
resizable: true, resizable: true,
sorter: true,
filterOptions: { filterOptions: {
type: 'enum-select', type: 'enum-select',
enumName: 'GOODS_STATUS_ENUM', enumName: 'GOODS_STATUS_ENUM',

View File

@ -56,7 +56,7 @@
row-key="employeeId" row-key="employeeId"
bordered bordered
> >
<template #bodyCell="{ text, record, index, column }"> <template #bodyCell="{ text, record, column }">
<template v-if="column.dataIndex === 'administratorFlag'"> <template v-if="column.dataIndex === 'administratorFlag'">
<a-tag color="error" v-if="text">超管</a-tag> <a-tag color="error" v-if="text">超管</a-tag>
</template> </template>

View File

@ -1,11 +1,6 @@
<template> <template>
<div> <div>
<template v-for="(item, index) in options"> <span>{{ dictValueName }}</span>
<template v-if="values.includes(item.valueCode)">
{{ item.valueName }}
<span> </span>
</template>
</template>
</div> </div>
</template> </template>
@ -21,8 +16,11 @@
// //
value: [Number, String, Array], value: [Number, String, Array],
}); });
const values = computed(() => { const dictValueName = computed(() => {
if (props.value === null || typeof props.value === 'undefined' || props.value === '') return []; if (props.value === null || typeof props.value === 'undefined' || props.value === '') return '';
return Array.isArray(props.value) ? props.value.map((item) => item.valueCode) : props.value.split(','); const valueCodeList = Array.isArray(props.value) ? props.value.map((item) => item.valueCode) : props.value.split(',');
const valueNameList = props.options.filter((item) => valueCodeList.includes(item.valueCode)).map((item) => item.valueName);
return valueNameList.join('');
}); });
</script> </script>

View File

@ -120,7 +120,7 @@
{{ text }} {{ text }}
</template> </template>
<template v-if="column.dataIndex === 'place'"> <template v-if="column.dataIndex === 'place'">
<DictPreview :options="descList.GOODS_PLACE" :value="text" /> <DictPreview :options="descList['GOODS_PLACE']" :value="text" />
</template> </template>
<template v-if="column.dataIndex === 'remark'"> <template v-if="column.dataIndex === 'remark'">
<span>{{ text ? text : '' }}</span> <span>{{ text ? text : '' }}</span>
@ -234,7 +234,6 @@
title: '商品状态', title: '商品状态',
dataIndex: 'goodsStatus', dataIndex: 'goodsStatus',
resizable: true, resizable: true,
sorter: true,
filterOptions: { filterOptions: {
type: 'enum-select', type: 'enum-select',
enumName: 'GOODS_STATUS_ENUM', enumName: 'GOODS_STATUS_ENUM',

View File

@ -56,7 +56,7 @@
row-key="employeeId" row-key="employeeId"
bordered bordered
> >
<template #bodyCell="{ text, record, index, column }"> <template #bodyCell="{ text, record, column }">
<template v-if="column.dataIndex === 'administratorFlag'"> <template v-if="column.dataIndex === 'administratorFlag'">
<a-tag color="error" v-if="text">超管</a-tag> <a-tag color="error" v-if="text">超管</a-tag>
</template> </template>