Przeglądaj źródła

加入了搜索接口

zhudie 1 rok temu
rodzic
commit
0c8d348e45

+ 2 - 1
src/api/scene/scene.ts

@@ -252,10 +252,11 @@ export const getCompanyLayoutApi = (params: { companyId: number; labelId: number
 // };
 
 /** 查询所有公司主页配置 */
-export const getCompanyLayoutList = () => {
+export const getCompanyLayoutList = (params: { name: string }) => {
   return http.request({
     url: '/homepageConfig/getCompanyLayoutList',
     method: 'get',
+    params,
   });
 };
 

+ 5 - 2
src/views/page-config/PageConfig.vue

@@ -17,7 +17,7 @@
       </div>
     </el-card>
     <el-card shadow="never" class="flex-1" style="margin-top: 8px; overflow: auto">
-      <PageMain />
+      <PageMain ref="pageMain" />
     </el-card>
   </div>
 </template>
@@ -28,8 +28,11 @@
   import PageMain from './component/PageMain.vue';
 
   const searchCom = ref('');
+  const pageMain = ref();
 
-  const searchPageConfig = () => {};
+  const searchPageConfig = () => {
+    pageMain.value.getList(searchCom.value);
+  };
 
   const broadcast = () => {
     ElMessage({

+ 9 - 10
src/views/page-config/component/PageMain.vue

@@ -69,15 +69,18 @@
   const companyLayoutList = ref<companyLayoutType[]>([]);
 
   onMounted(() => {
-    getCompanyLayoutList().then((res) => {
+    getList('');
+  });
+
+  const getList = (searchCom) => {
+    getCompanyLayoutList({ name: searchCom }).then((res) => {
       companyLayoutList.value = res;
       companyLayoutList.value = companyLayoutList.value.map((item) => {
         item.layout = JSON.parse(item.layout);
         return item;
       });
-      console.log('companyLayoutList.value', companyLayoutList.value);
     });
-  });
+  };
 
   const router = useRouter();
 
@@ -115,16 +118,12 @@
   const deleteItem = (item) => {
     // 处理删除逻辑
     delCompanyLayout(item.id).then(() => {
-      getCompanyLayoutList().then((res) => {
-        companyLayoutList.value = res;
-        companyLayoutList.value = companyLayoutList.value.map((item) => {
-          item.layout = JSON.parse(item.layout);
-          return item;
-        });
-      });
+      getList('');
     });
   };
 
+  defineExpose({ getList });
+
   // const label = ref('');
 </script>