123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <template>
- <div class="templateViewPanel">
- <div id="jsmind_container"></div>
- </div>
- </template>
- <script>
- import jsMind from "@/lib/jsmind";
- import "@/assets/common/css/jsmind.css";
- export default {
- name: "templateView", // 模板预览
- components: {},
- data() {
- return {
- mind: {},
- jm: {},
- options: {
- container: "jsmind_container",
- editable: false,
- theme: "primary",
- mode: "side",
- },
- };
- },
- props: {
- viewData: {
- type: Array,
- default: [],
- },
- errArr: {
- type: Array,
- default: [],
- },
- },
- watch: {
- viewData(val) {
- if (val && val.length > 0) {
- this.load_jsmind();
- }
- },
- },
- methods: {
- // 用jsmind插件,进行模板预览
- load_jsmind() {
- this.mind = {
- meta: {
- name: "templateView",
- },
- format: "node_array",
- data: this.viewData,
- };
- this.jm.show(this.mind);
- this.jm.expand_all();
- this.jm.enable_edit();
- this.errArr.forEach((i) => {
- this.jm.set_node_color(i, "red");
- });
- this.jm.disable_edit();
- },
- },
- mounted() {
- this.jm = new jsMind(this.options);
- this.load_jsmind();
- setTimeout(()=>{
- let body = $('.templateViewDia .el-dialog__body').height();
- let panel = $('.templateViewDia .templateViewPanel').height();
- if(panel < body - 10 ) {
- $('.templateViewDia .el-dialog__body').addClass('toCenter');
- }
- }, 0)
- },
- };
- </script>
- <style lang='less' scoped>
- .templateViewPanel {
- display: flex;
- justify-content: center;
- align-items: center;
- #jsmind_container {
- // display: flex;
- // justify-content: center;
- // align-items: center;
- // width: 94%;
- // height: calc(100% - 130px);
- // height: 100%;
- // min-height: 400px;
- // border: solid 1px #ccc;
- // background: #f4f4f4;
- overflow: auto;
- }
- }
- </style>
|