Browse Source

子表展示主表数据封装组件

master_hella_20240701
yufei0306 7 months ago
parent
commit
bf4b9b7ca1
  1. 8
      src/components/TableHead/src/TableHead.vue
  2. 7
      src/components/XButton/src/ButtonBase.vue
  3. 8
      src/components/rowDrop/index.vue
  4. 6
      src/hooks/web/useCrudSchemas.ts
  5. 2
      src/types/form.d.ts

8
src/components/TableHead/src/TableHead.vue

@ -10,7 +10,7 @@
<div class="tableNavRightBtns">
<!-- 右侧按钮 -->
<ButtonBase :Butttondata="buttonsRight" @button-base-click="buttonBaseClick" @updata-table-columns="updataTableColumns"
:allSchemas="allSchemas" ref="rowDropRef"/>
:allSchemas="allSchemas" :detailAllSchemas="detailAllSchemas" ref="rowDropRef"/>
</div>
</div>
<slot></slot>
@ -60,7 +60,11 @@ import rowDrop from "@/components/rowDrop/index.vue"
allSchemas: {
type: Object,
default: null
}
},
detailAllSchemas: {
type: Object,
default: null
},
})
const buttonsLeft = ref([])
const buttonsRight = ref([])

7
src/components/XButton/src/ButtonBase.vue

@ -25,6 +25,7 @@
ref="rowDropRef"
@updata-table-columns="updataTableColumns"
:allSchemas="allSchemas"
:detailAllSchemas="detailAllSchemas"
@closeRowDrop="closeRowDrop"
@updataTableColumns="updataTableColumns"
/>
@ -60,7 +61,11 @@ const props = defineProps({
allSchemas: {
type: Object,
default: null
}
},
detailAllSchemas: {
type: Object,
default: null
},
})
//

8
src/components/rowDrop/index.vue

@ -30,7 +30,11 @@ const props = defineProps({
allSchemas: {
type: Object,
default: null
}
},
detailAllSchemas: {
type: Object,
default: null
},
})
const popoverVisible = ref(false)
const route = useRoute() //
@ -121,7 +125,7 @@ const dragover = (e) => {
//
const initSelectSta = () => {
RedisApi.getRedis(routeName.value).then(res => {
const _myTableColumns = props.allSchemas?.tableColumns
let _myTableColumns = [...props.allSchemas?.tableColumns,...props.detailAllSchemas?.tableMainColumns]
//
if (res) {
checkedDataList.value = []

6
src/hooks/web/useCrudSchemas.ts

@ -67,6 +67,7 @@ interface AllSchemas {
formSchema: FormSchema[]
detailSchema: DescriptionsSchema[]
tableFormColumns: TableFormColumn[]
tableMainColumns:TableColumn[]
}
const { t } = useI18n()
@ -83,14 +84,17 @@ export const useCrudSchemas = (
tableColumns: [],
formSchema: [],
detailSchema: [],
tableFormColumns:[]
tableFormColumns:[],
tableMainColumns:[],
})
const searchSchema = filterSearchSchema(crudSchema, allSchemas)
allSchemas.searchSchema = searchSchema || []
const tableColumns = filterTableSchema(crudSchema)
allSchemas.tableColumns = tableColumns || []
allSchemas.tableMainColumns = tableColumns.filter(item=>!item.hiddenInMain) || []
const formSchema = filterFormSchema(crudSchema, allSchemas)
allSchemas.formSchema = formSchema

2
src/types/form.d.ts

@ -39,6 +39,8 @@ export type FormSchema = {
value?: FormValueType
// 是否隐藏
hidden?: boolean
//主表中展示子表数据
hiddenInMain?: boolean
// 远程加载下拉项
api?: <T = any>() => AxiosPromise<T>
}

Loading…
Cancel
Save