view-panel.tsx 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
import { ViewPanelModel } from '@ibiz-template/model';
import { useViewPanelController } from '@ibiz-template/vue-util';
import { defineComponent, getCurrentInstance, PropType } from 'vue';
import { IModal, ViewMode } from '@ibiz-template/runtime';

export const ViewPanel = defineComponent({
  props: {
    modelData: {
      type: ViewPanelModel,
      required: true,
    },
12
    context: { type: Object as PropType<IContext>, required: true },
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    params: { type: Object as PropType<IParams>, default: () => ({}) },
  },
  setup(props) {
    const { proxy } = getCurrentInstance()!;
    const c = useViewPanelController(
      proxy,
      props.modelData,
      props.context,
      props.params,
    );

    // 模态对象
    const modal: IModal = { mode: ViewMode.EMBED };

    // 视图模型路径
    const viewPath = c.model.embedView.source.modelPath;

    return { c, modal, viewPath };
  },
  render(h) {
    if (!this.c.complete) {
      return;
    }
    return h('ViewShell', {
37
      attrs: {
38 39 40 41 42 43 44 45 46 47 48
        context: this.c.context,
        params: this.c.params,
        modal: this.modal,
        modelPath: this.viewPath,
      },
      on: {
        neuronInit: this.c.nerve.onNeuronInit('embedView'),
      },
    });
  },
});