lijingjia 3 weeks ago
parent 57396bc432
commit 9371dd450d

@ -204,7 +204,12 @@ export default defineComponent({
}, },
emit, emit,
) )
// vxe
function getVxeSelectRows () {
console.log(tableElRef.value)
// console.log(tableElRef.value.getCheckboxRecords())
// return tableElRef.value.getCheckboxRecords()
}
function handleTableChange(...args) { function handleTableChange(...args) {
onTableChange.call(undefined, ...args) onTableChange.call(undefined, ...args)
emit('change', ...args) emit('change', ...args)
@ -291,7 +296,6 @@ export default defineComponent({
// } // }
propsData = omit(propsData, ['class', 'onChange']) propsData = omit(propsData, ['class', 'onChange'])
console.log(propsData)
return propsData return propsData
}) })
@ -328,6 +332,7 @@ export default defineComponent({
const tableAction: TableActionType = { const tableAction: TableActionType = {
reload, reload,
getSelectRows, getSelectRows,
getVxeSelectRows,
setSelectedRows, setSelectedRows,
clearSelectedRowKeys, clearSelectedRowKeys,
getSelectRowKeys, getSelectRowKeys,
@ -363,7 +368,7 @@ export default defineComponent({
}, },
} }
createTableContext({ ...tableAction, wrapRef, getBindValues }) createTableContext({ ...tableAction, wrapRef, getBindValues })
console.log(tableAction)
expose(tableAction) expose(tableAction)
emit('register', tableAction, formActions) emit('register', tableAction, formActions)
@ -376,8 +381,6 @@ export default defineComponent({
// props.rowDbClick(row) // props.rowDbClick(row)
} }
const vxeCheckBoxChange = (v) => { const vxeCheckBoxChange = (v) => {
setSelectedRows(v.row)
console.log(getSelectRows())
} }
return { return {
formRef, formRef,

@ -23,7 +23,6 @@ export function useTable(tableProps?: Props): [
const tableRef = ref<Nullable<TableActionType>>(null) const tableRef = ref<Nullable<TableActionType>>(null)
const loadedRef = ref<Nullable<boolean>>(false) const loadedRef = ref<Nullable<boolean>>(false)
const formRef = ref<Nullable<UseTableMethod>>(null) const formRef = ref<Nullable<UseTableMethod>>(null)
let stopWatch: WatchStopHandle let stopWatch: WatchStopHandle
function register(instance: TableActionType, formInstance: UseTableMethod) { function register(instance: TableActionType, formInstance: UseTableMethod) {
@ -32,7 +31,6 @@ export function useTable(tableProps?: Props): [
tableRef.value = null tableRef.value = null
loadedRef.value = null loadedRef.value = null
}) })
if (unref(loadedRef) && isProdMode() && instance === unref(tableRef)) return if (unref(loadedRef) && isProdMode() && instance === unref(tableRef)) return
tableRef.value = instance tableRef.value = instance
@ -110,6 +108,9 @@ export function useTable(tableProps?: Props): [
getSelectRows: () => { getSelectRows: () => {
return toRaw(getTableInstance().getSelectRows()) return toRaw(getTableInstance().getSelectRows())
}, },
getVxeSelectRows: () => {
return getTableInstance().getVxeSelectRows()
},
clearSelectedRowKeys: () => { clearSelectedRowKeys: () => {
getTableInstance().clearSelectedRowKeys() getTableInstance().clearSelectedRowKeys()
}, },

@ -86,6 +86,7 @@ export interface TableActionType {
reload: (opt?: FetchParams) => Promise<void> reload: (opt?: FetchParams) => Promise<void>
setSelectedRows: (rows: Recordable[]) => void setSelectedRows: (rows: Recordable[]) => void
getSelectRows: <T = Recordable>() => T[] getSelectRows: <T = Recordable>() => T[]
getVxeSelectRows: () => []
clearSelectedRowKeys: () => void clearSelectedRowKeys: () => void
expandAll: () => void expandAll: () => void
expandRows: (keys: string[] | number[]) => void expandRows: (keys: string[] | number[]) => void

Loading…
Cancel
Save