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.
- package/README.md +11 -11
- package/lib/iconfont.svg +155 -155
- package/lib/index.js +1 -1
- package/lib/tianheng-ui.js +2 -2
- package/package.json +1 -1
- package/packages/formMaking/Container.vue +601 -601
- package/packages/formMaking/CusDialog.vue +134 -134
- package/packages/formMaking/FormConfig.vue +40 -40
- package/packages/formMaking/GenerateForm.vue +184 -184
- package/packages/formMaking/Upload/index.vue +572 -572
- package/packages/formMaking/WidgetForm.vue +268 -268
- package/packages/formMaking/generateCode.js +154 -154
- package/packages/formMaking/iconfont/demo.css +539 -539
- package/packages/formMaking/iconfont/demo_index.html +1159 -1159
- package/packages/formMaking/iconfont/iconfont.css +189 -189
- package/packages/formMaking/iconfont/iconfont.svg +155 -155
- package/packages/formMaking/index.js +77 -77
- package/packages/formMaking/lang/en-US.js +187 -187
- package/packages/formMaking/lang/zh-CN.js +187 -187
- package/packages/formMaking/styles/cover.scss +40 -40
- package/packages/formMaking/styles/index.scss +746 -746
- package/packages/formMaking/util/index.js +32 -32
- package/packages/formMaking/util/request.js +28 -28
@@ -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
|
}
|