kuaifan 5 vuotta sitten
vanhempi
commit
939e0b9891

+ 1 - 1
app/Http/Controllers/Api/DocsController.php

@@ -200,7 +200,7 @@ class DocsController extends Controller
             return Base::retSuccess('修改成功!', $data);
         } else {
             // 添加
-            if (!in_array($type, ['document', 'mind', 'sheet', 'chart', 'folder'])) {
+            if (!in_array($type, ['document', 'mind', 'sheet', 'flow', 'folder'])) {
                 return Base::retError('参数错误!');
             }
             $parentid = 0;

+ 74 - 0
resources/assets/js/main/components/docs/flow/index.vue

@@ -0,0 +1,74 @@
+<template>
+    <div class="flow-content">
+        <iframe ref="myFlow" class="flow-iframe" :src="url"></iframe>
+    </div>
+</template>
+
+<style lang="scss" scoped>
+    .flow-content {
+        position: absolute;
+        top: 0;
+        left: 0;
+        width: 100%;
+        height: 100%;
+        .flow-iframe {
+            position: absolute;
+            top: 0;
+            left: 0;
+            width: 100%;
+            height: 100%;
+            background: 0 0;
+            border: 0;
+            float: none;
+            margin: -1px 0 0;
+            max-width: none;
+            outline: 0;
+            padding: 0;
+        }
+    }
+</style>
+<script>
+
+    export default {
+        name: "Flow",
+        props: {
+            value: {
+                type: ''
+            },
+        },
+        data() {
+            return {
+                flow: null,
+                url: window.location.origin + '/js/grapheditor/index.html',
+            }
+        },
+        mounted() {
+            window.addEventListener('message', this.handleMessage)
+            this.flow = this.$refs.myFlow.contentWindow;
+        },
+        activated() {
+            window.addEventListener('message', this.handleMessage)
+            this.flow = this.$refs.myFlow.contentWindow;
+        },
+        methods: {
+            handleMessage (event) {
+                // 根据上面制定的结构来解析iframe内部发回来的数据
+                const data = event.data;
+                switch (data.act) {
+                    case 'ready':
+                        this.flow.postMessage({
+                            act: 'setXml',
+                            params: {
+                                xml: this.value,
+                            }
+                        }, '*')
+                        break
+
+                    case 'change':
+                        this.$emit('input', data.params.xml);
+                        break
+                }
+            }
+        },
+    }
+</script>

+ 16 - 2
resources/assets/js/main/components/docs/sheet/index.vue

@@ -29,6 +29,8 @@
         data() {
             return {
                 sheet: null,
+                clientHeight: 0,
+                clientWidth: 0,
             }
         },
         mounted() {
@@ -36,8 +38,20 @@
             //
             this.sheet = new Spreadsheet(this.$refs.xspreadsheet, {
                 view: {
-                    height: () => this.$refs.xspreadsheet.clientHeight,
-                    width: () => this.$refs.xspreadsheet.clientWidth,
+                    height: () => {
+                        try {
+                            return this.clientHeight = this.$refs.xspreadsheet.clientHeight;
+                        }catch (e) {
+                            return this.clientHeight;
+                        }
+                    },
+                    width: () => {
+                        try {
+                            return this.clientWidth = this.$refs.xspreadsheet.clientWidth;
+                        }catch (e) {
+                            return this.clientWidth;
+                        }
+                    },
                 },
             }).loadData(this.value).change(data => {
                 this.$emit('input', data);

+ 1 - 1
resources/assets/js/main/pages/docs.vue

@@ -223,7 +223,7 @@
                     {value: 'document', text: "文本"},
                     {value: 'mind', text: "脑图"},
                     {value: 'sheet', text: "表格"},
-                    {value: 'chart', text: "流程图"},
+                    {value: 'flow', text: "流程图"},
                     {value: 'folder', text: "目录"},
                 ],
 

+ 3 - 1
resources/assets/js/main/pages/docs/edit.vue

@@ -18,6 +18,7 @@
                 <t-editor v-if="docDetail.type=='document'" class="body-text" v-model="docContent.content" height="100%"></t-editor>
                 <minder v-else-if="docDetail.type=='mind'" class="body-mind" @exportData="exportMindData" :template="docContent.template" :theme="docContent.theme" :importData="docContent.root"></minder>
                 <sheet v-else-if="docDetail.type=='sheet'" class="body-sheet" v-model="docContent.content"></sheet>
+                <flow v-else-if="docDetail.type=='flow'" class="body-flow" v-model="docContent.content"></flow>
             </div>
         </div>
 
@@ -156,11 +157,12 @@
     import minder from '../../components/docs/minder'
     import TEditor from "../../components/TEditor";
     import Sheet from "../../components/docs/sheet/index";
+    import Flow from "../../components/docs/flow/index";
 
     Vue.use(minder)
 
     export default {
-        components: {Sheet, TEditor},
+        components: {Flow, Sheet, TEditor},
         data () {
             return {
                 loadIng: 0,