grid-view.tsx 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import { IModal } from '@ibiz-template/runtime';
import { useGridViewController } from '@ibiz-template/vue-util';
import {
  defineComponent,
  getCurrentInstance,
  onActivated,
  PropType,
} from 'vue';

export const GridView = 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> },
16
    noLoadDefault: { type: Boolean, required: false },
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  },
  setup(props) {
    const { proxy } = getCurrentInstance()!;

    const c = useGridViewController(proxy, props.modelPath);

    // 表格视图激活刷新
    onActivated(() => c.refresh());

    return { c };
  },
  render(h) {
    let gridComponent = null;
    if (this.c.complete) {
      const { grid } = this.c.model;
      if (this.c.providers[grid.name]) {
        gridComponent = h(this.c.providers[grid.name].component, {
          props: {
            modelData: grid,
            context: this.c.context,
            params: this.c.params,
38
            modal: this.modal,
39 40 41 42 43 44 45 46 47 48 49
            'grid-row-active-mode': this.c.model.gridRowActiveMode,
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(grid.name),
          },
        });
      }
    }
    return <md-view-base controller={this.c}>{gridComponent}</md-view-base>;
  },
});