app-design.vue 4.8 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
<template>
    <div class="app-model-setting" v-if="sdc.isShowTool">
        <!-- <div class="app-design-button" @click="handleButtonClick">
            <icon type="md-settings" />
        </div>
        <drawer :closable="false" class-name="app-design-drawer" :width="800" v-model="isShowDrawer">
            <div class="app-model-setting-button" @click="handleButtonClick">
                <icon type="md-close" />
            </div>
            <iframe class="app-modle-setting-content" height="100%" width="100%" scrolling="true" :src="iframeUrl" />
        </drawer> -->
    </div>
</template>

<script lang="ts">
import { AppServiceBase, StudioActionUtil, Util } from 'ibiz-core';
import { Subject } from 'rxjs';
import { AppDesign } from './app-design';
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';

@Component({})
export default class AppModelSetting extends Vue {
    /**
     * 动态参数
     *
     * @memberof AppModelSetting
     */
    @Prop() public dynamicProps!: any;

    /**
     * 是否显示抽屉
     *
     * @memberof AppModelSetting
     */
    public isShowDrawer: boolean = false;

    /**
     * 数据传递对象
     *
     * @type {*}
     * @memberof AppModelSetting
     */

    public subject: Subject<any> = new Subject<any>();

    /**
     * iframe路径
     *
     * @memberof AppModelSetting
     */
    public iframeUrl: string = '';

    /**
     * 配置平台操作控制器
     *
     * @type {StudioActionUtil}
     * @memberof AppModelSetting
     */
    public sdc: StudioActionUtil = StudioActionUtil.getInstance();

    /**
     * 获取数据传递对象
     *
     * @memberof AppModelSetting
     */
    public getSubject() {
        return this.subject;
    }

    /**
     * 监听部件动态参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof AppModelSetting
     */
    @Watch('dynamicProps', {
        immediate: true,
    })
    public onDynamicPropsChange(newVal: any, oldVal: any) {
        if (newVal && !Util.isFieldsSame(newVal, oldVal)) {
            this.setIframeUrl(newVal);
        }
    }

    /**
     * Vue声明周期
     *
     * @memberof AppModelSetting
     */
    public created() {
        // window.addEventListener('message', async (e: MessageEvent) => {
        //     const appEnvironment: any = AppServiceBase.getInstance().getAppEnvironment();
        //     if (e.origin !== appEnvironment.previewDynaPath) {
        //         return;
        //     }
        //     this.isShowDrawer = !this.isShowDrawer;
        //     this.subject.next({ tag: 'message', action: 'close', data: e?.data });
        // });
    }

    public destroyed() {
        AppDesign.getInstance().destroyVueExample();
    }

    /**
     * 处理按钮点击
     *
     * @memberof AppModelSetting
     */
    public handleButtonClick() {
        this.isShowDrawer = !this.isShowDrawer;
    }

    /**
     * 设置iframe路径
     *
     * @memberof AppModelSetting
     */
    public setIframeUrl(data: any) {
        const appEnvironment: any = AppServiceBase.getInstance().getAppEnvironment();
        this.iframeUrl = `${appEnvironment.previewDynaPath}/dynamictool/modelresmarket/#/modelresmarket/${data.srfdynainstid}/psuwprojects/applymodelresview?objectid=${data.objectid}`;
    }
}
</script>
<style lang="less">
.app-model-setting {
    width: 100%;
    height: 100%;
    .app-design-button {
        position: fixed;
        top: 300px;
        right: 4px;
        font-size: 48px;
        color: #fff;
        background: #1890ff;
        width: 56px;
        height: 56px;
        text-align: center;
        line-height: 56px;
        border-radius: 6px;
        cursor: pointer;
        .ivu-icon {
            vertical-align: 0;
        }
    }
}
.app-design-drawer {
    .ivu-drawer {
        .ivu-drawer-content {
            background-color: rgba(55, 55, 55, 0);
            box-shadow: none;
            .ivu-drawer-body {
                padding: 0px !important;
                .app-model-setting-button {
                    position: absolute;
                    font-size: 48px;
                    color: #fff;
                    background: #1890ff;
                    width: 56px;
                    height: 56px;
                    text-align: center;
                    line-height: 56px;
                    border-radius: 6px;
                    top: 300px;
                    left: 0px;
                    cursor: pointer;
                    .ivu-icon {
                        vertical-align: 0;
                    }
                }
                .app-modle-setting-content {
                    background-color: #fff;
                    width: calc(100% - 56px);
                    height: calc(100% - 8px);
                    margin-left: 56px;
                    box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
                }
            }
        }
    }
}
</style>