Blame view

frontend/manage/src/components/form/dataTemplate/TemplatePreviewDialog.vue 2.33 KB
8ea9c133   陈威   初始化提交
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
<template>
  <v-runtime-template :template="html"/>
</template>
<script>
import form from "@/api/form.js";
import VRuntimeTemplate from "v-runtime-template";
import { Base64 } from "js-base64";

export default {
  name: "templatePreview",
  components: {
    VRuntimeTemplate,
  },
  props: {
    alias: String,
  },
  data() {
    return {
      templateInfo:{},
      data: [],
      html: '',
      pageResult: {
        page: 1,
        pageSize: 20,
        total: 0
      },
    };
  },
  watch: {
    alias: function(newVal) {
      if (newVal) {
        this.init();
      }
    }
  },
  mounted() {
    if(this.alias){
      this.init();
    }
  },
  methods: {
    init(){
      let _me = this;
      form.getTemplateDataListForm(this.alias)
        .then(result => {
        if (result.state) {
            _me.html = result.value;
        }
      });
      form.getBpmDataTemplateInfo(this.alias)
        .then(result => {
          if (result.state) {
            _me.templateInfo = result.value;
            if (_me.templateInfo.displayField) {
              let displayField = JSON.parse( _me.templateInfo.displayField);
              for (var i = 0; i < displayField.length; i++) {
                if (displayField[i].type) {
                  this.displayFields.push(displayField[i]);
                }
              }
            }
          }
      });
    },
    loadData(param, cb) {
      form
        .getDataTemplateData(param)
        .then(response => {
          this.data = response.rows;

          this.pageResult = {
            page: response.page,
            pageSize: response.pageSize,
            total: response.total
          };
        })
        .finally(() => cb());
    },
    handleCommand(params) {
      switch (params.command) {
        case "edit":
          this.templateId = params.row.id;
          this.editFormTemplate(this.templateId);
          break;
        case "delete":
          break;
        case "assignUser":
          break;
        case "assignMenu":
          break;
        default:
          break;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.el-main {
  padding-top: 0px;
}

.form-editor-dialog >>> .el-dialog__header {
  display: none;
}

.form-editor-dialog >>> .el-dialog__body {
  padding: 0;
  height: 100%;
}

div >>> .el-dialog__body {
  height: calc(100% - 10px);
  padding: 10px;
}
</style>