Blame view

src/views/workflow/components/zdt.vue 1.14 KB
1 2 3
<!--
 * @Description: 
 * @Autor: renchao
4
 * @LastEditTime: 2023-09-18 14:06:16
5 6
-->
<template>
7
  <div style="width:100%;height:100%;">
8
    <canvas id="mxcad" style="width:100%;height:100%;">
9 10
    </canvas>
  </div>
11 12 13 14 15 16 17 18 19 20 21
</template>
<script>
  import Mx from "mxdraw"
  export default {
    mounted () {
      // 动态加载 js库核心代码
      Mx.loadCoreCode().then(() => {
        // Mx.MxFun.setMxServer("ws://localhost:5090") // 开启socket通信 可编辑图纸
        // 创建控件对象
        Mx.MxFun.createMxObject({
          canvasId: "mxcad", // canvas元素的id
22
          cadFile: "buf/hhhh.dwg", // http方式(预览): 加载public/demo文件夹下转换后的图纸
23 24 25 26 27 28 29 30 31 32
          callback: (mxDraw, {
            canvas,
            canvasParent
          }) => {
            // 可以拿到canvas元素和它的父级元素
            // 拿到图层数据
            mxDraw.addEvent('uiSetLayerData', (listLayer) => {
              console.log(listLayer)
            })
          },
33
          isNewFile: true // 是否新建文件
34 35
        })
      })
36
    },
37
  }
38 39 40 41 42 43
</script>
<style scoped lang="scss">
  #mxcad {
    pointer-events: none;
  }
</style>