feat: 字典标签支持取默认数据项
This commit is contained in:
@@ -15,14 +15,24 @@ const props = defineProps({
|
|||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
/**数据默认值,当前值不存在时 */
|
||||||
|
valueOption: {
|
||||||
|
type: [Number, String],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/**遍历找到对应值数据项 */
|
/**遍历找到对应值数据项 */
|
||||||
const item = computed(() => {
|
const item = computed(() => {
|
||||||
if (Array.isArray(props.options) && props.options.length > 0) {
|
if (Array.isArray(props.options) && props.options.length > 0) {
|
||||||
const option = (props.options as any[]).find(
|
let option = (props.options as any[]).find(
|
||||||
item => `${item[props.valueField]}` === `${props.value}`
|
item => `${item[props.valueField]}` === `${props.value}`
|
||||||
);
|
);
|
||||||
|
// 数据默认值
|
||||||
|
if (props.valueOption != undefined && !option) {
|
||||||
|
option = (props.options as any[]).find(
|
||||||
|
item => `${item[props.valueField]}` === `${props.valueOption }`
|
||||||
|
);
|
||||||
|
}
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ onMounted(() => {
|
|||||||
<div class="card-cdr-item">
|
<div class="card-cdr-item">
|
||||||
<div>
|
<div>
|
||||||
{{ t('views.dashboard.overview.userActivity.caller') }}:
|
{{ t('views.dashboard.overview.userActivity.caller') }}:
|
||||||
<span :title="item.data.callerParty">{{
|
<span :title="item.data.callerParty">
|
||||||
item.data.callerParty
|
{{ item.data.callerParty }}
|
||||||
}}</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ t('views.dashboard.overview.userActivity.called') }}:
|
{{ t('views.dashboard.overview.userActivity.called') }}:
|
||||||
@@ -104,7 +104,7 @@ onMounted(() => {
|
|||||||
<div>
|
<div>
|
||||||
{{ t('views.dashboard.overview.userActivity.result') }}:
|
{{ t('views.dashboard.overview.userActivity.result') }}:
|
||||||
<span v-if="item.data.callType !== 'sms'">
|
<span v-if="item.data.callType !== 'sms'">
|
||||||
<DictTag :options="dict.cdrSipCode" :value="item.data.cause" />
|
<DictTag :options="dict.cdrSipCode" :value="item.data.cause" value-option="0" />
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
{{ t('views.dashboard.overview.userActivity.resultOK') }}
|
{{ t('views.dashboard.overview.userActivity.resultOK') }}
|
||||||
|
|||||||
Reference in New Issue
Block a user