Преглед изворни кода

feat: 选择场景添加搜索

bill пре 2 година
родитељ
комит
6560efbc95
1 измењених фајлова са 15 додато и 7 уклоњено
  1. 15 7
      src/views/scene/select-scenes.vue

+ 15 - 7
src/views/scene/select-scenes.vue

@@ -6,7 +6,14 @@
       :tab="option.label"
     />
   </a-tabs>
+  <a-input-search
+    v-model:value="sceneName"
+    allow-clear
+    placeholder="请输入场景名称"
+    @search="params.sceneName = sceneName"
+  />
   <a-table
+    style="margin-top: 10px"
     row-key="num"
     :data-source="list"
     :columns="sceneColumns"
@@ -24,7 +31,7 @@
 
 <script lang="ts" setup>
 import { selectSceneColumns as sceneColumns } from './columns'
-import { reactive } from 'vue'
+import { reactive, ref } from 'vue'
 import { fetchScenes, SceneType, SceneTypeDesc } from '@/api'
 import { usePaging } from '@/hook'
 
@@ -37,11 +44,6 @@ const emit = defineEmits<{
   (e: 'update:typeNums', value: SelectTypeScenes): void
 }>()
 
-const updateType = (type: any) => {
-  pagination.current = 1
-  params.type = type
-}
-
 const tabOptions = [SceneType.SWKJ, SceneType.SWKK, SceneType.SWSS].map(
   type => ({
     key: type,
@@ -50,9 +52,15 @@ const tabOptions = [SceneType.SWKJ, SceneType.SWKK, SceneType.SWSS].map(
 )
 
 const defaultTypeNums = { ...props.typeNums }
-const params = reactive({ type: SceneType.SWSS })
+const sceneName = ref('')
+const params = reactive({ type: SceneType.SWSS, sceneName: '' })
 const { list, pagination } = usePaging(fetchScenes, params)
 
+const updateType = (type: any) => {
+  pagination.current = 1
+  params.type = type
+}
+
 const changeSelectNums = (nums: any[]) => {
   const currentNums = props.typeNums[params.type]
   const reserve = currentNums.filter(num =>