Browse Source

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

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

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

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

8
src/components/rowDrop/index.vue

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

6
src/hooks/web/useCrudSchemas.ts

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

2
src/types/form.d.ts

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

Loading…
Cancel
Save