import { IModal } from '@ibiz-template/runtime'; import { useNamespace, useMPickupView2Controller, } from '@ibiz-template/vue-util'; import { defineComponent, getCurrentInstance, PropType, ref, Ref, VNode, } from 'vue'; import '@ibiz-template/theme/style/components/views/mpickup-view2/mpickup-view2.scss'; export const MPickupView2 = defineComponent({ props: { context: Object as PropType, params: { type: Object as PropType, default: () => ({}) }, modelPath: { type: String, required: true }, modal: { type: Object as PropType }, noLoadDefault: { type: Boolean, required: false }, }, setup(props) { const { proxy } = getCurrentInstance()!; const c = useMPickupView2Controller(proxy, props.modelPath); const ns = useNamespace('view-dempickupview2'); // UI层单击选中的数组 const UISelections: Ref = ref([]); const isSelected = (selection: IData) => { return UISelections.value.includes(selection); }; const addRight = () => { c.addSelectData(); UISelections.value = []; }; const addRightAll = () => { c.selectAll(); UISelections.value = []; }; const removeRight = () => { c.removeSelections(UISelections.value); UISelections.value = []; }; const removeRightAll = () => { c.removeAllSelections(); UISelections.value = []; }; const handleSelectionClick = (selection: IData) => { const index = UISelections.value.indexOf(selection); if (index === -1) { UISelections.value.push(selection); } else { UISelections.value.splice(index, 1); } }; return { ns, c, addRight, addRightAll, removeRight, removeRightAll, isSelected, handleSelectionClick, }; }, 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 ( { return (
{ this.c.onOkButtonClick(); }} > 确定 { this.c.onCancelButtonClick(); }} > 取消
); }, }} >
{treeComponent}
{panelComponent}
{'>'} {'<'} {'>>'} {'<<'}
{this.c.selfSelection.map(item => { return (
this.handleSelectionClick(item)} > {item.srfmajortext} { this.c.removeSelections([item]); }} />
); })}
); }, });