|
|
@@ -95,8 +95,9 @@
|
|
|
<span class="status-label" :style="state.style">{{ state.text }}</span>
|
|
|
</template>
|
|
|
<script setup lang="ts" name="ExtDLabel">
|
|
|
-import {onMounted, reactive,watch} from 'vue';
|
|
|
+import {onMounted, onBeforeUnmount, reactive,watch} from 'vue';
|
|
|
import {Session} from "/@/utils/storage";
|
|
|
+import mittBus from '/@/utils/mitt';
|
|
|
import u from "/@/utils/u";
|
|
|
|
|
|
// const emit = defineEmits(['update:value']);
|
|
|
@@ -137,6 +138,11 @@ watch(()=>props.modelValue,(oldVal,newVal)=>{
|
|
|
|
|
|
onMounted(() => {
|
|
|
setupLabel()
|
|
|
+ mittBus.on("dictsLoaded", setupLabel);
|
|
|
+});
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ mittBus.off("dictsLoaded", setupLabel);
|
|
|
});
|
|
|
|
|
|
const setupLabel = ()=>{
|
|
|
@@ -146,28 +152,31 @@ const setupLabel = ()=>{
|
|
|
let {label, color} = data;
|
|
|
state.text = label;
|
|
|
state.style = setupColorStyle(color);
|
|
|
+ } else {
|
|
|
+ state.text = props.modelValue != null ? String(props.modelValue) : '-';
|
|
|
+ state.style = setupColorStyle('#909399');
|
|
|
}
|
|
|
} else {
|
|
|
let dicts = [];
|
|
|
const sessionDicts = Session.get("dicts");
|
|
|
if (!u.isEmptyOrNull(sessionDicts)) {
|
|
|
- dicts =sessionDicts[`${props.type}`]
|
|
|
- if(u.isEmptyOrNull(dicts)){
|
|
|
- return "-";
|
|
|
- }
|
|
|
- }else{
|
|
|
- dicts =state.dicts[`${props.type}`]
|
|
|
- if(u.isEmptyOrNull(dicts)){
|
|
|
- return "-";
|
|
|
- }
|
|
|
+ dicts = sessionDicts[`${props.type}`]
|
|
|
+ } else {
|
|
|
+ dicts = state.dicts[`${props.type}`]
|
|
|
+ }
|
|
|
+ if (u.isEmptyOrNull(dicts)) {
|
|
|
+ state.text = props.modelValue != null ? String(props.modelValue) : '-';
|
|
|
+ state.style = setupColorStyle('#909399');
|
|
|
+ return;
|
|
|
}
|
|
|
let dict = (<Dicts>dicts).find(k => k.value == props.modelValue);
|
|
|
|
|
|
if (dict) {
|
|
|
state.text = dict.name||dict.label;
|
|
|
state.style = setupColorStyle(dict.color || state.colorList[dict.value%8||dict.value.length%8]);
|
|
|
- }else{
|
|
|
- return "-"
|
|
|
+ } else {
|
|
|
+ state.text = props.modelValue != null ? String(props.modelValue) : '-';
|
|
|
+ state.style = setupColorStyle('#909399');
|
|
|
}
|
|
|
}
|
|
|
}
|