Browse Source

fix: 角色key相同返回值不同

xyh 2 năm trước cách đây
mục cha
commit
8de17d2f1c
2 tập tin đã thay đổi với 11 bổ sung7 xóa
  1. 1 1
      src/pages/home/index.vue
  2. 10 6
      src/pages/user/table/modal/Info.vue

+ 1 - 1
src/pages/home/index.vue

@@ -10,7 +10,7 @@ const {t} = useI18n();
 </script>
 
 <template>
-  <ErrorBoundary>
+  <ErrorBoundary keepEmit>
     <template #fallback="{reset, error}">
       <main style="width: 100vw;height: 100vh">
         <LDErrorBoundary :msg="error.message" @reset="reset" />

+ 10 - 6
src/pages/user/table/modal/Info.vue

@@ -49,16 +49,20 @@ const {isLoading, data: options} = useQuery({
   async queryFn({signal}) {
     const data = await getAllRole(signal);
 
-    if (data.msg === '200') {
-      return data.data.map(function(val) {
-        return {label: val.roleName, value: val.id};
-      });
-    }
+    if (data.msg === '200')
+      return data.data;
 
     return [];
   },
   cacheTime: 1000 * 60,
 });
+
+const optionList = computed(function() {
+  return options.value?.map(function(val) {
+    return {label: val.roleName, value: val.id};
+  });
+});
+
 </script>
 
 <template>
@@ -68,7 +72,7 @@ const {isLoading, data: options} = useQuery({
     name="role"
     :label="t('user.table[4]')"
     :loading="isLoading"
-    :options="options"
+    :options="optionList"
   />
   <LDModalInput name="email" :label="t('user.table[2]')" />
   <LDModalInput name="phone" :label="t('user.table[3]')" />