import { useNamespace } from '@ibiz-template/vue-util'; import { computed, defineComponent, PropType, ref, watch } from 'vue'; import './exp-view-base.scss'; import { IExpBarModel } from '@ibiz-template/model'; import { ListExpViewController } from '@ibiz-template/controller'; export const ExpViewBase = defineComponent({ name: 'ExpViewBase', props: { controller: { type: Object as PropType, required: true, }, expBarModel: { type: Object as PropType, }, }, setup(props) { const ns = useNamespace('exp-view'); const cssVars = ref({}); watch( () => props.expBarModel?.width, (newVal, oldVal) => { if (newVal !== oldVal && newVal) { cssVars.value = ns.cssVarBlock({ 'left-width': `${newVal}px`, }); } }, ); // 是否显示头部 const isShowHeader = computed(() => { return ( props.expBarModel?.showTitleBar || props.expBarModel?.enableSearch || props.controller.model.toolbar ); }); return { ns, cssVars, isShowHeader }; }, render() { const c = this.controller; // 外面的插槽同样传给view-layout const inheritSlots: IData = {}; Object.keys(this.$scopedSlots).forEach(key => { inheritSlots[key] = (arg: IData) => this.$scopedSlots[key]!(arg); }); return (
{ return (
{c.complete && c.model.source.getPSSysImage() ? ( [ , {c.caption} , ] ) : ( {c.caption} )}
); }, ...inheritSlots, default: () => { return (
{this.expBarModel?.showTitleBar && (this.expBarModel?.getPSSysImage ? ( [ , {this.expBarModel?.title} , ] ) : ( {this.expBarModel?.title} ))}
{c.complete && this.expBarModel?.enableSearch && ( { c.query = val; }} onSearch={() => c.onSearch()} > )}
{c.complete && c.model.toolbar && ( )}
{inheritSlots.default && inheritSlots.default()}
); }, }} >
{this.$scopedSlots.expView && this.$scopedSlots.expView({})}
); }, });