Browse Source

标签管理 修改标签分类选项搜索逻辑

cc12458 10 months ago
parent
commit
1d2624f087
1 changed files with 14 additions and 7 deletions
  1. 14 7
      src/pages/index/system/tag.vue

+ 14 - 7
src/pages/index/system/tag.vue

@@ -53,7 +53,10 @@ const searchFormProps = reactive<VxeFormProps<TagQuery>>({
         options: [
           { label: '系统', value: '1' },
           { label: '个人', value: '2' },
-        ]
+        ],
+        events: {
+          change(value: { data: TagQuery }) { onSearch(value.data) },
+        },
       }
     },
     {
@@ -68,14 +71,18 @@ const searchFormProps = reactive<VxeFormProps<TagQuery>>({
   ],
 });
 const searchFormEmits: VxeFormListeners<TagQuery> = {
-  submit({ data }) {
-    /* 修正 types 全空无效 */
-    if (!data.types?.length) data.types = ['1', '2']
-    model.value = { ...data };
-  },
-  reset({ data }) { model.value = { ...data, }; },
+  submit({ data }) { onSearch(data); },
+  reset({ data }) { onSearch(data) },
 };
 
+function onSearch(data: TagQuery) {
+  const types: TagQuery['types'] = data.types?.length ? data.types : ['1', '2'];
+  model.value = { ...data, types: [...types] };
+  nextTick(() => {
+    searchFormProps.data!.types = [...types];
+  })
+}
+
 const gridRef = ref<VxeGridInstance<TagModel>>();
 const gridOptions = reactive<VxeGridProps<TagModel>>({
   id: 'tag-list',