Blame view

application/admin/view/exam/cert_template/script.html 3.56 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
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
  <script>

      var app = new Vue({

          el: '#app',

          data: {

              form: {

                  user_name: {

                      status: 1,

                      size: 30,

                      color: '#000000',

                      x: 200,

                      y: 300

                  },

                  score: {

                      status: 1,

                      size: 30,

                      color: '#000000',

                      x: 200,

                      y: 400

                  }

              }

          },

          created() {

              // this.getForm()

              this.initData();

              this.setFieldConfig();

              this.onPreview();

          },

          methods: {

              initData() {

                  let field_config = $('#field_config').val();

                  if (field_config) {

                    if (field_config = JSON.parse(field_config)) {

                      this.form = field_config;

                    }

                  }

              },

  

              setFieldConfig() {

                $('#field_config').val(JSON.stringify(this.form));

              },

  

              handleChange(e) {

                  console.log('handleChange', e);

                  this.onPreview();

              },

  

              onPreview() {

                  // this.handleChange();

                  let image = $('#c-image').val();

                  let user_name = this.form.user_name;

                  let score = this.form.score;

  

                  if (!image) {

                      this.warnTips('请先上传证书模板');

                      return;

                  }

                  if (!user_name.size || user_name.size < 1) {

                      this.warnTips('姓名的字体大小必须大于0');

                      return;

                  }

                  if (!score.size || score.size < 1) {

                      this.warnTips('分数的字体大小必须大于0');

                      return;

                  }

  

                  let preview_url = $('#preview_url').val();

                  $('#iframe_cert_image').attr('src', preview_url + '?image=' + image + '&user_name=' + encodeURIComponent(JSON.stringify(user_name)) + '&score=' + encodeURIComponent(JSON.stringify(score)));

                  this.setFieldConfig();

              },

  

              warnTips($msg) {

                  this.$message({

                      message: $msg,

                      type: 'warning'

                  });

              },

  

              getForm() {

                  var timer = setInterval(() => {

                      if (faForm) {

                          clearInterval(timer);

                          console.log('faForm3', faForm);

                          this.bindForm();

                      }

                  }, 500);

              },

              bindForm() {

                  faForm.api.bindevent($("form[role=form]"), function(data, ret){

                      console.log('bindevent', data, ret);

                      if (ret.code == 1) {

                          Fast.api.close(data);

                      }

                      return false;

                  });

              },

              changePage(e) {

                  console.log('changePage', e)

                  this.currentPage = e.target.value;

                  this.currentItem = this.pages.find(item => item.path === this.currentPage);

  

                  setTimeout(() => {

                      if (faForm) {

                          this.bindForm();

                      }

                  }, 500);

              },

              // 验证

              valid() {

  

              }

          }

      });

  </script>