222
schangxiang@126.com
2025-04-30 9bec4dcae002f36aa23231da11cb03a156b40110
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// @ts-nocheck
import { defineComponent, useAttrs, ref, SetupContext, PropType } from 'vue'
import BaseTable from './index.vue'
import type { TablePropsItemType } from './index.d'
// 注释时间2024-10-09
// 该表格是从多个小项目迁移改造而来,经历过多重改造,代码比较乱,如果需要重构,请基于components/BaseTable/BaseTable.tsx继续重构。
// 另外本地vxe-table和线上vxe-table版本不一致,有可能有差异性,比如watch数据不执行等。注意避坑。
export default defineComponent<TablePropsItemType>({
  props: BaseTable.props,
  // emits: BaseTable.emits,
  setup(props, ctx: SetupContext) {
    // const emits: any = BaseTable.emits
    // const eventMap: Record<string, any> = {}
    const tableRef = ref()
 
    // emits.forEach((eventName: string) => {
    //   const onEventName = `on${eventName
    //     .slice(0, 1)
    //     .toUpperCase()}${eventName.slice(1)}`
    //   eventMap[onEventName] = (...args: any) => ctx.emit(eventName, ...args)
    // })
 
    /**
     * 暴露方法
     * @param exposeMap
     */
    const onUpdatedExpose = (exposeMap: Record<string, () => void>) => {
      ctx.expose(exposeMap)
    }
 
    return () => {
      return (
        <BaseTable
          ref={tableRef}
          {...props}
          {...ctx.attrs}
          // {...eventMap}
          v-slots={{ ...ctx.slots }}
          onUpdate={onUpdatedExpose}
        />
      )
    }
  },
})