tianheng-ui 0.0.46 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,155 +1,155 @@
1
- function findRemoteFunc (list, funcList, tokenFuncList, blankList) {
2
- for (let i = 0; i < list.length; i++) {
3
- if (list[i].type == 'grid') {
4
- list[i].columns.forEach(item => {
5
- findRemoteFunc(item.list, funcList, tokenFuncList, blankList)
6
- })
7
- } else {
8
- if (list[i].type == 'blank') {
9
- if (list[i].model) {
10
- blankList.push({
11
- name: list[i].model,
12
- label: list[i].name
13
- })
14
- }
15
- } else if (list[i].type == 'imgupload') {
16
- if (list[i].options.tokenFunc) {
17
- tokenFuncList.push({
18
- func: list[i].options.tokenFunc,
19
- label: list[i].name,
20
- model: list[i].model
21
- })
22
- }
23
- } else {
24
- if (list[i].options.remote && list[i].options.remoteFunc) {
25
- funcList.push({
26
- func: list[i].options.remoteFunc,
27
- label: list[i].name,
28
- model: list[i].model
29
- })
30
- }
31
- }
32
- }
33
- }
34
- }
35
-
36
- export default function (data, type = 'vue') {
37
-
38
- const funcList = []
39
-
40
- const tokenFuncList = []
41
-
42
- const blankList = []
43
-
44
- findRemoteFunc(JSON.parse(data).list, funcList, tokenFuncList, blankList)
45
-
46
- let funcTemplate = ''
47
-
48
- let blankTemplate = ''
49
-
50
- for(let i = 0; i < funcList.length; i++) {
51
- funcTemplate += `
52
- ${funcList[i].func} (resolve) {
53
- // ${funcList[i].label} ${funcList[i].model}
54
- // Call callback function once get the data from remote server
55
- // resolve(data)
56
- },
57
- `
58
- }
59
-
60
- for(let i = 0; i < tokenFuncList.length; i++) {
61
- funcTemplate += `
62
- ${tokenFuncList[i].func} (resolve) {
63
- // ${tokenFuncList[i].label} ${tokenFuncList[i].model}
64
- // Call callback function once get the token
65
- // resolve(token)
66
- },
67
- `
68
- }
69
-
70
- for (let i = 0; i < blankList.length; i++) {
71
- blankTemplate += `
72
- <template slot="${blankList[i].name}" slot-scope="scope">
73
- <!-- ${blankList[i].label} -->
74
- <!-- use v-model="scope.model.${blankList[i].name}" to bind data -->
75
- </template>
76
- `
77
- }
78
-
79
- if (type == 'vue') {
80
- return `<template>
81
- <div>
82
- <fm-generate-form :data="jsonData" :remote="remoteFuncs" :value="editData" ref="generateForm">
83
- ${blankTemplate}
84
- </fm-generate-form>
85
- <el-button type="primary" @click="handleSubmit">提交</el-button>
86
- </div>
87
- </template>
88
-
89
- <script>
90
- export default {
91
- data () {
92
- return {
93
- jsonData: ${data},
94
- editData: {},
95
- remoteFuncs: {
96
- ${funcTemplate}
97
- }
98
- }
99
- },
100
- methods: {
101
- handleSubmit () {
102
- this.$refs.generateForm.getData().then(data => {
103
- // data check success
104
- // data - form data
105
- }).catch(e => {
106
- // data check failed
107
- })
108
- }
109
- }
110
- }
111
- </script>`
112
- } else {
113
- return `<!DOCTYPE html>
114
- <html>
115
- <head>
116
- <meta charset="UTF-8">
117
- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
118
- <link rel="stylesheet" href="https://unpkg.com/form-making/dist/FormMaking.css">
119
- </head>
120
- <body>
121
- <div id="app">
122
- <fm-generate-form :data="jsonData" :remote="remoteFuncs" :value="editData" ref="generateForm">
123
- ${blankTemplate}
124
- </fm-generate-form>
125
- <el-button type="primary" @click="handleSubmit">提交</el-button>
126
- </div>
127
- <script src="https://unpkg.com/vue/dist/vue.js"></script>
128
- <script src="https://unpkg.com/element-ui/lib/index.js"></script>
129
- <script src="https://unpkg.com/form-making/dist/FormMaking.umd.js"></script>
130
- <script>
131
- new Vue({
132
- el: '#app',
133
- data: {
134
- jsonData: ${data},
135
- editData: {},
136
- remoteFuncs: {
137
- ${funcTemplate}
138
- }
139
- },
140
- methods: {
141
- handleSubmit () {
142
- this.$refs.generateForm.getData().then(data => {
143
- // data check success
144
- // data - form data
145
- }).catch(e => {
146
- // data check failed
147
- })
148
- }
149
- }
150
- })
151
- </script>
152
- </body>
153
- </html>`
154
- }
1
+ function findRemoteFunc (list, funcList, tokenFuncList, blankList) {
2
+ for (let i = 0; i < list.length; i++) {
3
+ if (list[i].type == 'grid') {
4
+ list[i].columns.forEach(item => {
5
+ findRemoteFunc(item.list, funcList, tokenFuncList, blankList)
6
+ })
7
+ } else {
8
+ if (list[i].type == 'blank') {
9
+ if (list[i].model) {
10
+ blankList.push({
11
+ name: list[i].model,
12
+ label: list[i].name
13
+ })
14
+ }
15
+ } else if (list[i].type == 'imgupload') {
16
+ if (list[i].options.tokenFunc) {
17
+ tokenFuncList.push({
18
+ func: list[i].options.tokenFunc,
19
+ label: list[i].name,
20
+ model: list[i].model
21
+ })
22
+ }
23
+ } else {
24
+ if (list[i].options.remote && list[i].options.remoteFunc) {
25
+ funcList.push({
26
+ func: list[i].options.remoteFunc,
27
+ label: list[i].name,
28
+ model: list[i].model
29
+ })
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ export default function (data, type = 'vue') {
37
+
38
+ const funcList = []
39
+
40
+ const tokenFuncList = []
41
+
42
+ const blankList = []
43
+
44
+ findRemoteFunc(JSON.parse(data).list, funcList, tokenFuncList, blankList)
45
+
46
+ let funcTemplate = ''
47
+
48
+ let blankTemplate = ''
49
+
50
+ for(let i = 0; i < funcList.length; i++) {
51
+ funcTemplate += `
52
+ ${funcList[i].func} (resolve) {
53
+ // ${funcList[i].label} ${funcList[i].model}
54
+ // Call callback function once get the data from remote server
55
+ // resolve(data)
56
+ },
57
+ `
58
+ }
59
+
60
+ for(let i = 0; i < tokenFuncList.length; i++) {
61
+ funcTemplate += `
62
+ ${tokenFuncList[i].func} (resolve) {
63
+ // ${tokenFuncList[i].label} ${tokenFuncList[i].model}
64
+ // Call callback function once get the token
65
+ // resolve(token)
66
+ },
67
+ `
68
+ }
69
+
70
+ for (let i = 0; i < blankList.length; i++) {
71
+ blankTemplate += `
72
+ <template slot="${blankList[i].name}" slot-scope="scope">
73
+ <!-- ${blankList[i].label} -->
74
+ <!-- use v-model="scope.model.${blankList[i].name}" to bind data -->
75
+ </template>
76
+ `
77
+ }
78
+
79
+ if (type == 'vue') {
80
+ return `<template>
81
+ <div>
82
+ <fm-generate-form :data="jsonData" :remote="remoteFuncs" :value="editData" ref="generateForm">
83
+ ${blankTemplate}
84
+ </fm-generate-form>
85
+ <el-button type="primary" @click="handleSubmit">提交</el-button>
86
+ </div>
87
+ </template>
88
+
89
+ <script>
90
+ export default {
91
+ data () {
92
+ return {
93
+ jsonData: ${data},
94
+ editData: {},
95
+ remoteFuncs: {
96
+ ${funcTemplate}
97
+ }
98
+ }
99
+ },
100
+ methods: {
101
+ handleSubmit () {
102
+ this.$refs.generateForm.getData().then(data => {
103
+ // data check success
104
+ // data - form data
105
+ }).catch(e => {
106
+ // data check failed
107
+ })
108
+ }
109
+ }
110
+ }
111
+ </script>`
112
+ } else {
113
+ return `<!DOCTYPE html>
114
+ <html>
115
+ <head>
116
+ <meta charset="UTF-8">
117
+ <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
118
+ <link rel="stylesheet" href="https://unpkg.com/form-making/dist/FormMaking.css">
119
+ </head>
120
+ <body>
121
+ <div id="app">
122
+ <fm-generate-form :data="jsonData" :remote="remoteFuncs" :value="editData" ref="generateForm">
123
+ ${blankTemplate}
124
+ </fm-generate-form>
125
+ <el-button type="primary" @click="handleSubmit">提交</el-button>
126
+ </div>
127
+ <script src="https://unpkg.com/vue/dist/vue.js"></script>
128
+ <script src="https://unpkg.com/element-ui/lib/index.js"></script>
129
+ <script src="https://unpkg.com/form-making/dist/FormMaking.umd.js"></script>
130
+ <script>
131
+ new Vue({
132
+ el: '#app',
133
+ data: {
134
+ jsonData: ${data},
135
+ editData: {},
136
+ remoteFuncs: {
137
+ ${funcTemplate}
138
+ }
139
+ },
140
+ methods: {
141
+ handleSubmit () {
142
+ this.$refs.generateForm.getData().then(data => {
143
+ // data check success
144
+ // data - form data
145
+ }).catch(e => {
146
+ // data check failed
147
+ })
148
+ }
149
+ }
150
+ })
151
+ </script>
152
+ </body>
153
+ </html>`
154
+ }
155
155
  }