11
schangxiang@126.com
2025-05-19 a593dfae54de741b8ca84d375357c5ca130faccb
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import {
  Component,
  DefineComponent,
  defineComponent,
  markRaw,
  ref,
  SetupContext,
  onMounted,
} from 'vue'
import styles from './PipeAccessoryPick.module.scss'
import Tab from '@/components/Tab/Tab'
import { useProvideModels } from '@/libs/Provider/app'
import { usePermission } from '@/libs/Permission/Permission'
import { permissionCodes } from '../enum'
import { ModuleType, TabItem } from '../type/Type'
import { getEntityNames } from '@/hooks/hook'
import TabPane from '@/components/Tab/TabPane'
 
const Models: ModuleType = import.meta.glob('./config/*.json', {
  eager: true,
})
 
const entityNames = getEntityNames(Models)
 
const nameToLabelMap = [{ name: 'PipeAccessoryPick', label: '分拣' }]
 
export default defineComponent({
  name: 'PipeAccessoryPick',
 
  setup(props, ctx: SetupContext) {
    useProvideModels()
    usePermission(props, permissionCodes)
 
    const rf = ref<{
      [key: string]: any
    }>({})
 
    const tabData = ref<TabItem[]>([])
 
    const onTabChange = (v: string) => {
      rf.value?.[v]?.reloadList()
    }
 
    const initTableData = async () => {
      for (const i in entityNames) {
        const name = entityNames[i]
        const module = await import(`./Pages/${name}/${name}.tsx`)
        const PipeAccessoryPick = markRaw(module.default)
        const foundLabel =
          nameToLabelMap.find((item) => item.name === name)?.label || name
        tabData.value.push({
          label: foundLabel,
          name,
          component: PipeAccessoryPick,
        })
      }
    }
 
    initTableData()
 
    return () => {
      return (
        <div class={styles.PipeAccessoryPick}>
          <Tab data={tabData.value} type="list" onTab={onTabChange}>
            {tabData.value.map((widgetInfo) => {
              const Widget: any = widgetInfo.component
              return (
                <TabPane label={widgetInfo.label} name={widgetInfo.name}>
                  <Widget
                    ref={(r: any) => (rf.value['PipeAccessoryPick'] = r)}
                  ></Widget>
                </TabPane>
              )
            })}
          </Tab>
        </div>
      )
    }
  },
})