Prechádzať zdrojové kódy

修复容器组件子级配置可搜索无效的bug

tongshangming 2 rokov pred
rodič
commit
bf725183b4

+ 9 - 2
src/components/core/ProTable.vue

@@ -7,7 +7,7 @@ export default {
 <script setup lang="ts">
 import router from '@/router'
 import { ElMessage, ElMessageBox, type DialogProps } from 'element-plus'
-import type { AdvancedForm, BasicForm, ICRUD, FormSlot } from '@/types/form'
+import type { AdvancedForm, BasicForm, BasicFormItem, ICRUD, FormSlot } from '@/types/form'
 import type { VXEComponent, VxeToolbarProps, VxeToolbarEventProps } from 'vxe-table'
 import { buildFormSlots } from '@/utils/utils'
 
@@ -43,6 +43,13 @@ const slots = useSlots()
 // ============== 查询部分开始 ===============
 const query = ref<any>({})
 const searchList = ref<any>([])
+// 构造搜索列表
+const buildSearchList = (item: BasicFormItem) => {
+  if (item.search) {
+    searchList.value.push(Object.assign({}, item, { props: { ...item.props, disabled: false } }))
+  }
+  item.children && item.children.forEach(buildSearchList)
+}
 watch(
   () => props.formConfig.formItems,
   val => {
@@ -51,7 +58,7 @@ watch(
       if (item.group) {
         searchList.value = searchList.value.concat(item.group.filter((item: any) => item.search))
       } else {
-        item.search && searchList.value.push(item)
+        buildSearchList(item)
       }
     })
   },

+ 2 - 2
src/views/system/Dict.vue

@@ -119,8 +119,8 @@ const dictItemFormConfig = reactive<BasicForm>({
 </script>
 
 <template>
-  <el-row :gutter="16">
-    <el-col :span="12">
+  <el-row :gutter="16" class="h-full">
+    <el-col :span="12" class="h-full">
       <pro-table :crud="CRUD" :formConfig="dictFormConfig" :row-class-name="rowClassName" @cell-click="handleRowClick">
         <vxe-column field="description" title="字典名称"></vxe-column>
         <vxe-column field="type" title="字典值"></vxe-column>

+ 2 - 2
src/views/system/Role.vue

@@ -105,8 +105,8 @@ const handleSubmit = () => {
 </script>
 
 <template>
-  <el-row :gutter="16">
-    <el-col :span="curRole ? 12 : 24">
+  <el-row :gutter="16" class="h-full">
+    <el-col :span="curRole ? 12 : 24" class="h-full">
       <pro-table :crud="CRUD" :formConfig="formConfig" :tableConfig="{ operateWidth: 220 }">
         <vxe-column field="name" title="角色名称"></vxe-column>
         <vxe-column field="enname" title="英文名称"></vxe-column>