ibiz-activiti-full-screen.component.ts 1.9 KB
Newer Older
MoneyQ's avatar
MoneyQ committed
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
Vue.component('ibiz-activiti-full-screen', {
    template: `
        <div style="width:100%; height:100%;">
            <iframe width="100%" height="100%" ref="ibizactivitifullscreen" :src="url" frameborder="0" ></iframe>
        </div>
    `,
    props: ['params'],
    data: function () {
        let data: any = {
            wfDesign: new IBizWFDesignField2({ vue: this, workFlow: this.params.workFlow }),
            $iframeIsLoadEnd: false,
            workflowDesign: null,
        };
        const url = `../../../packages/assets/plugins/static/activiti/index.html?fsmode=true&_=${data.wfDesign.newGuid()}`;
        Object.assign(data, { url: url });
        if (this.params && this.params.activitiModel) {
            Object.assign(data, { activitiModel: this.params.activitiModel });
        }
        return data;
    },
    mounted: function () {
        this.designInit();
        if (this.wfDesign) {
            this.wfDesign.setValue(this.activitiModel);
        }
    },
    methods: {
        designInit() {
            let iframe: any = this.$refs.ibizactivitifullscreen;
            if (!iframe) {
                return;
            }
            this.workflowDesign = iframe.contentWindow;
            if (this.workflowDesign) {
                this.workflowDesign.onload = () => {
                    this.wfDesign.setFlowFrame(this.workflowDesign);
                    this.wfDesign.onFlowFrameLoad();
                    this.$iframeIsLoadEnd = true;
                    // this.wfDesign.setValue(this.activitiModel);
                };
                this.workflowDesign.onSelectionChanged = () => {
                    let activitiModel = this.wfDesign.getValue();
                    this.$emit('dataChange', { ret: 'OK', activitiModel: activitiModel });
                };
                this.isDesignInitEnd = true;
            } else {
                console.error('设计工具初始化失败');
            }
        }
    }
});