pickup-view2.tsx 2.1 KB
Newer Older
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
import { IModal } from '@ibiz-template/runtime';
import {
  useNamespace,
  usePickupView2Controller,
} from '@ibiz-template/vue-util';
import { defineComponent, getCurrentInstance, PropType, VNode } from 'vue';
import '@ibiz-template/theme/style/components/views/pickup-view2/pickup-view2.scss';

export const PickupView2 = defineComponent({
  props: {
    context: Object as PropType<IContext>,
    params: { type: Object as PropType<IParams>, default: () => ({}) },
    modelPath: { type: String, required: true },
    modal: { type: Object as PropType<IModal> },
    noLoadDefault: { type: Boolean, required: false },
  },
  setup(props) {
    const { proxy } = getCurrentInstance()!;
    const c = usePickupView2Controller(proxy, props.modelPath);
    const ns = useNamespace('view-depickupview2');
    return { c, ns };
  },
  render(h) {
    let panelComponent = null;
    let treeComponent: VNode | null = null;

    if (this.c.complete) {
      const { tree, pickupViewPanel } = this.c.model;
      if (this.c.providers[tree.name]) {
        treeComponent = h(this.c.providers[tree.name].component, {
          props: {
            modelData: tree,
            context: this.c.context,
            params: this.c.params,
            isSelectFirstDefault: true,
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit('tree'),
          },
        });
      }
      if (this.c.providers[pickupViewPanel.name]) {
        panelComponent = h(this.c.providers[pickupViewPanel.name].component, {
          props: {
            modelData: pickupViewPanel,
            context: this.c.navPanelParams.context,
            params: this.c.navPanelParams.params,
            noLoadDefault: true,
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(pickupViewPanel.name),
          },
        });
      }
    }
    return (
      <view-base controller={this.c}>
        <div class={this.ns.b('container')}>
          <div class={this.ns.b('left')}>{treeComponent}</div>
          <div class={this.ns.b('right')}>{panelComponent}</div>
        </div>
      </view-base>
    );
  },
});