Blame view

application/admin/view/exam/config_info/frontend.html 3.84 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
  <script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>

  <script src="__CDN__/assets/addons/exam/js/vue.js"></script>

  

  <div id="app">

    <form class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" id="setForm">

      <div class="form-group">

        <label class="control-label col-xs-12 col-sm-2">跳转页面:</label>

        <div class="col-xs-12 col-sm-8">

          <select name="info[url]" id="type" class="form-control" @change="changePage" v-model="currentPage">

            <option value="">请选择</option>

            <option v-for="(item, index) in pages" :value="item.path" :key="index">{{item.name}}</option>

          </select>

        </div>

      </div>

  

      <div v-if="currentItem && currentItem.params">

        <div class="form-group" v-for="(item, index) in currentItem.params" :key="index">

          <label class="control-label col-xs-12 col-sm-2">{{item.name}}{{item.require ? '(必填)' : ''}}:</label>

          <div class="col-xs-12 col-sm-8">

            <input v-if="item.type == 'string'" id="c-param_value" data-rule="required" class="form-control" :name="'info[params]['+item.field+']'" type="text" :value="item.value">

  

            <input v-if="item.type == 'selectpage'" id="c-param_value" :data-rule="item.require ? 'required' : ''" min="0" :data-source="item.selectpage.source" :data-field="item.selectpage.field" class="form-control selectpage" :name="'info[params]['+item.field+']'" type="text" :value="item.value">

          </div>

        </div>

      </div>

  

      <!--<input type="hidden" name="type" value="system">-->

      <div class="form-group layer-footer">

        <label class="control-label col-xs-12 col-sm-2"></label>

        <div class="col-xs-12 col-sm-8">

          <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>

          <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>

        </div>

      </div>

    </form>

  </div>

  

  <script>

    var faForm = null;

    var parentFrontendInfo = $('#c-front_info', parent.document).val();

    var pages = {:json_encode($pages, 256)};

  

    var app = new Vue({

      el: '#app',

      data: {

        pages: [],

        currentPage: '',

        currentItem: null,

        parentFrontendInfo: null,

  

      },

      created() {

        this.pages = pages

        this.getForm()

  

        if (parentFrontendInfo) {

          this.parentFrontendInfo = JSON.parse(parentFrontendInfo);

          this.currentPage = this.parentFrontendInfo.url;

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

          if (this.currentItem && this.currentItem.params) {

            this.currentItem.params.forEach(item => {

              item.value = this.parentFrontendInfo.params[item.field];

            })

          }

          console.log('this.parentFrontendInfo', this.parentFrontendInfo)

          console.log('this.currentPage', this.currentPage)

          console.log('this.currentItem', this.currentItem)

        }

      },

      methods: {

        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>