mini-form-render 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +15 -15
- package/package.json +43 -43
- package/src/app.mpx +27 -27
- package/src/components/basic-input.mpx +35 -35
- package/src/components/basic-picker.mpx +79 -79
- package/src/components/form.mpx +140 -136
- package/src/pages/form-render.mpx +47 -47
- package/src/pages/index.mpx +51 -51
- package/src/pages/js-logic-render.mpx +59 -59
- package/src/pages/server-scheme.mpx +75 -75
- package/src/test/paint-form.js +43 -43
- package/src/test/scheme1.js +22 -22
- package/src/test/server-relation-scheme.js +33 -33
- package/static/wx/project.config.json +61 -61
- package/vue.config.js +16 -16
@@ -1,75 +1,75 @@
|
|
1
|
-
<template>
|
2
|
-
<view class="form-demo-page">
|
3
|
-
<view style="content: ''; overflow: hidden;"></view>
|
4
|
-
|
5
|
-
<view class="form-demo-container">
|
6
|
-
<view class="form-title">服务端联动表单渲染测试</view>
|
7
|
-
<form-render class="form-render-container" scheme="{{formScheme}}" bindformchange="handleFormChange"/>
|
8
|
-
</view>
|
9
|
-
</view>
|
10
|
-
</template>
|
11
|
-
|
12
|
-
<script>
|
13
|
-
import { createPage } from '@mpxjs/core'
|
14
|
-
import serverScheme from '../test/server-relation-scheme'
|
15
|
-
|
16
|
-
createPage({
|
17
|
-
data: {
|
18
|
-
formScheme: [],
|
19
|
-
formResult: null
|
20
|
-
},
|
21
|
-
onLoad() {
|
22
|
-
console.log('onLoad, server scheme is:', serverScheme)
|
23
|
-
// this.formScheme = scheme1
|
24
|
-
this.initFormScheme()
|
25
|
-
},
|
26
|
-
watch: {
|
27
|
-
formResult() {
|
28
|
-
this.initFormScheme()
|
29
|
-
}
|
30
|
-
},
|
31
|
-
methods: {
|
32
|
-
initFormScheme() {
|
33
|
-
const formProperties = []
|
34
|
-
serverScheme.properties.forEach(item => {
|
35
|
-
if (item.condition) {
|
36
|
-
const condition = item.condition
|
37
|
-
if (this.formResult && this.formResult[condition.key] === condition.value) {
|
38
|
-
formProperties.push(item)
|
39
|
-
}
|
40
|
-
} else {
|
41
|
-
formProperties.push(item)
|
42
|
-
}
|
43
|
-
})
|
44
|
-
this.formScheme = { properties: formProperties }
|
45
|
-
},
|
46
|
-
handleFormChange(e) {
|
47
|
-
console.log('form change handler: ', e.detail)
|
48
|
-
this.formResult = e.detail
|
49
|
-
}
|
50
|
-
}
|
51
|
-
})
|
52
|
-
</script>
|
53
|
-
|
54
|
-
<style lang="stylus">
|
55
|
-
page
|
56
|
-
background-color #f5f5f5
|
57
|
-
|
58
|
-
.form-demo-container
|
59
|
-
background #fff
|
60
|
-
margin 24rpx
|
61
|
-
border-radius 16rpx
|
62
|
-
padding 24rpx
|
63
|
-
|
64
|
-
.form-render-container {
|
65
|
-
margin-top 24rpx
|
66
|
-
}
|
67
|
-
</style>
|
68
|
-
|
69
|
-
<script type="application/json">
|
70
|
-
{
|
71
|
-
"usingComponents": {
|
72
|
-
"form-render": "../components/form"
|
73
|
-
}
|
74
|
-
}
|
75
|
-
</script>
|
1
|
+
<template>
|
2
|
+
<view class="form-demo-page">
|
3
|
+
<view style="content: ''; overflow: hidden;"></view>
|
4
|
+
|
5
|
+
<view class="form-demo-container">
|
6
|
+
<view class="form-title">服务端联动表单渲染测试</view>
|
7
|
+
<form-render class="form-render-container" scheme="{{formScheme}}" bindformchange="handleFormChange"/>
|
8
|
+
</view>
|
9
|
+
</view>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
import { createPage } from '@mpxjs/core'
|
14
|
+
import serverScheme from '../test/server-relation-scheme'
|
15
|
+
|
16
|
+
createPage({
|
17
|
+
data: {
|
18
|
+
formScheme: [],
|
19
|
+
formResult: null
|
20
|
+
},
|
21
|
+
onLoad() {
|
22
|
+
console.log('onLoad, server scheme is:', serverScheme)
|
23
|
+
// this.formScheme = scheme1
|
24
|
+
this.initFormScheme()
|
25
|
+
},
|
26
|
+
watch: {
|
27
|
+
formResult() {
|
28
|
+
this.initFormScheme()
|
29
|
+
}
|
30
|
+
},
|
31
|
+
methods: {
|
32
|
+
initFormScheme() {
|
33
|
+
const formProperties = []
|
34
|
+
serverScheme.properties.forEach(item => {
|
35
|
+
if (item.condition) {
|
36
|
+
const condition = item.condition
|
37
|
+
if (this.formResult && this.formResult[condition.key] === condition.value) {
|
38
|
+
formProperties.push(item)
|
39
|
+
}
|
40
|
+
} else {
|
41
|
+
formProperties.push(item)
|
42
|
+
}
|
43
|
+
})
|
44
|
+
this.formScheme = { properties: formProperties }
|
45
|
+
},
|
46
|
+
handleFormChange(e) {
|
47
|
+
console.log('form change handler: ', e.detail)
|
48
|
+
this.formResult = e.detail
|
49
|
+
}
|
50
|
+
}
|
51
|
+
})
|
52
|
+
</script>
|
53
|
+
|
54
|
+
<style lang="stylus">
|
55
|
+
page
|
56
|
+
background-color #f5f5f5
|
57
|
+
|
58
|
+
.form-demo-container
|
59
|
+
background #fff
|
60
|
+
margin 24rpx
|
61
|
+
border-radius 16rpx
|
62
|
+
padding 24rpx
|
63
|
+
|
64
|
+
.form-render-container {
|
65
|
+
margin-top 24rpx
|
66
|
+
}
|
67
|
+
</style>
|
68
|
+
|
69
|
+
<script type="application/json">
|
70
|
+
{
|
71
|
+
"usingComponents": {
|
72
|
+
"form-render": "../components/form"
|
73
|
+
}
|
74
|
+
}
|
75
|
+
</script>
|
package/src/test/paint-form.js
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
const getFormScheme = (formRes) => {
|
2
|
-
const baseScheme = {
|
3
|
-
properties: [model]
|
4
|
-
}
|
5
|
-
|
6
|
-
baseScheme.properties.push(formRes.model !== '二次元' ? templateDream : templateAnything)
|
7
|
-
|
8
|
-
const formScheme = baseScheme
|
9
|
-
|
10
|
-
return formScheme
|
11
|
-
}
|
12
|
-
|
13
|
-
const model = {
|
14
|
-
key: 'model',
|
15
|
-
type: 'string',
|
16
|
-
title: '模型选择',
|
17
|
-
widget: 'picker',
|
18
|
-
customData: {
|
19
|
-
pickerArr: ['绘梦', '二次元']
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
const templateDream = {
|
24
|
-
key: 'template',
|
25
|
-
type: 'string',
|
26
|
-
title: '模板选择',
|
27
|
-
widget: 'picker',
|
28
|
-
customData: {
|
29
|
-
pickerArr: ['油画', '风景', '水彩']
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
const templateAnything = {
|
34
|
-
key: 'template',
|
35
|
-
type: 'string',
|
36
|
-
title: '模板选择',
|
37
|
-
widget: 'picker',
|
38
|
-
customData: {
|
39
|
-
pickerArr: ['幻想', '动漫']
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
export default getFormScheme
|
1
|
+
const getFormScheme = (formRes) => {
|
2
|
+
const baseScheme = {
|
3
|
+
properties: [model]
|
4
|
+
}
|
5
|
+
|
6
|
+
baseScheme.properties.push(formRes.model !== '二次元' ? templateDream : templateAnything)
|
7
|
+
|
8
|
+
const formScheme = baseScheme
|
9
|
+
|
10
|
+
return formScheme
|
11
|
+
}
|
12
|
+
|
13
|
+
const model = {
|
14
|
+
key: 'model',
|
15
|
+
type: 'string',
|
16
|
+
title: '模型选择',
|
17
|
+
widget: 'picker',
|
18
|
+
customData: {
|
19
|
+
pickerArr: ['绘梦', '二次元']
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
const templateDream = {
|
24
|
+
key: 'template',
|
25
|
+
type: 'string',
|
26
|
+
title: '模板选择',
|
27
|
+
widget: 'picker',
|
28
|
+
customData: {
|
29
|
+
pickerArr: ['油画', '风景', '水彩']
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
const templateAnything = {
|
34
|
+
key: 'template',
|
35
|
+
type: 'string',
|
36
|
+
title: '模板选择',
|
37
|
+
widget: 'picker',
|
38
|
+
customData: {
|
39
|
+
pickerArr: ['幻想', '动漫']
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
export default getFormScheme
|
package/src/test/scheme1.js
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
export default {
|
2
|
-
properties: [
|
3
|
-
{
|
4
|
-
key: 'model',
|
5
|
-
type: 'string',
|
6
|
-
title: '模型选择',
|
7
|
-
widget: 'picker',
|
8
|
-
customData: {
|
9
|
-
pickerArr: ['绘梦', '二次元', '真人']
|
10
|
-
}
|
11
|
-
},
|
12
|
-
{
|
13
|
-
key: 'template',
|
14
|
-
type: 'string',
|
15
|
-
title: '模板选择',
|
16
|
-
widget: 'picker',
|
17
|
-
customData: {
|
18
|
-
pickerArr: ['油画', '水彩', '风景']
|
19
|
-
}
|
20
|
-
}
|
21
|
-
]
|
22
|
-
}
|
1
|
+
export default {
|
2
|
+
properties: [
|
3
|
+
{
|
4
|
+
key: 'model',
|
5
|
+
type: 'string',
|
6
|
+
title: '模型选择',
|
7
|
+
widget: 'picker',
|
8
|
+
customData: {
|
9
|
+
pickerArr: ['绘梦', '二次元', '真人']
|
10
|
+
}
|
11
|
+
},
|
12
|
+
{
|
13
|
+
key: 'template',
|
14
|
+
type: 'string',
|
15
|
+
title: '模板选择',
|
16
|
+
widget: 'picker',
|
17
|
+
customData: {
|
18
|
+
pickerArr: ['油画', '水彩', '风景']
|
19
|
+
}
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
@@ -1,33 +1,33 @@
|
|
1
|
-
// 服务端下发且需要联动的scheme,前端整理后进行渲染
|
2
|
-
export default {
|
3
|
-
properties: [
|
4
|
-
{
|
5
|
-
key: 'model',
|
6
|
-
title: '模型选择',
|
7
|
-
widget: 'picker',
|
8
|
-
customData: {
|
9
|
-
pickerArr: ['绘梦', '二次元', '真人']
|
10
|
-
},
|
11
|
-
children: [
|
12
|
-
{
|
13
|
-
key: 'template',
|
14
|
-
title: '模板选择',
|
15
|
-
widget: 'picker',
|
16
|
-
condition: '绘梦',
|
17
|
-
customData: {
|
18
|
-
pickerArr: ['油画', '水彩', '风景']
|
19
|
-
}
|
20
|
-
},
|
21
|
-
{
|
22
|
-
key: 'template',
|
23
|
-
title: '模板选择',
|
24
|
-
widget: 'picker',
|
25
|
-
condition: '二次元',
|
26
|
-
customData: {
|
27
|
-
pickerArr: ['测试1', '测试2', '测试3']
|
28
|
-
}
|
29
|
-
}
|
30
|
-
]
|
31
|
-
}
|
32
|
-
]
|
33
|
-
}
|
1
|
+
// 服务端下发且需要联动的scheme,前端整理后进行渲染
|
2
|
+
export default {
|
3
|
+
properties: [
|
4
|
+
{
|
5
|
+
key: 'model',
|
6
|
+
title: '模型选择',
|
7
|
+
widget: 'picker',
|
8
|
+
customData: {
|
9
|
+
pickerArr: ['绘梦', '二次元', '真人']
|
10
|
+
},
|
11
|
+
children: [
|
12
|
+
{
|
13
|
+
key: 'template',
|
14
|
+
title: '模板选择',
|
15
|
+
widget: 'picker',
|
16
|
+
condition: '绘梦',
|
17
|
+
customData: {
|
18
|
+
pickerArr: ['油画', '水彩', '风景']
|
19
|
+
}
|
20
|
+
},
|
21
|
+
{
|
22
|
+
key: 'template',
|
23
|
+
title: '模板选择',
|
24
|
+
widget: 'picker',
|
25
|
+
condition: '二次元',
|
26
|
+
customData: {
|
27
|
+
pickerArr: ['测试1', '测试2', '测试3']
|
28
|
+
}
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
]
|
33
|
+
}
|
@@ -1,62 +1,62 @@
|
|
1
|
-
{
|
2
|
-
"setting": {
|
3
|
-
"newFeature": true,
|
4
|
-
"urlCheck": true,
|
5
|
-
"es6": false,
|
6
|
-
"postcss": true,
|
7
|
-
"minified": false,
|
8
|
-
"checkSiteMap": false,
|
9
|
-
"autoAudits": false,
|
10
|
-
"coverView": true,
|
11
|
-
"lazyloadPlaceholderEnable": false,
|
12
|
-
"preloadBackgroundData": false,
|
13
|
-
"uglifyFileName": false,
|
14
|
-
"uploadWithSourceMap": true,
|
15
|
-
"enhance": false,
|
16
|
-
"useMultiFrameRuntime": true,
|
17
|
-
"showShadowRootInWxmlPanel": true,
|
18
|
-
"packNpmManually": false,
|
19
|
-
"packNpmRelationList": [],
|
20
|
-
"minifyWXSS": true,
|
21
|
-
"useStaticServer": true,
|
22
|
-
"showES6CompileOption": false,
|
23
|
-
"checkInvalidKey": true,
|
24
|
-
"babelSetting": {
|
25
|
-
"ignore": [],
|
26
|
-
"disablePlugins": [],
|
27
|
-
"outputPath": ""
|
28
|
-
},
|
29
|
-
"disableUseStrict": false,
|
30
|
-
"useCompilerPlugins": false,
|
31
|
-
"minifyWXML": true,
|
32
|
-
"compileHotReLoad": true,
|
33
|
-
"ignoreUploadUnusedFiles": false,
|
34
|
-
"condition": false
|
35
|
-
},
|
36
|
-
"appid": "wx74053e55da62dcd3",
|
37
|
-
"projectname": "mpxdemo",
|
38
|
-
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
39
|
-
"condition": {
|
40
|
-
"miniprogram": {
|
41
|
-
"list": [
|
42
|
-
{
|
43
|
-
"name": "服务端下发",
|
44
|
-
"pathName": "pages/server-scheme",
|
45
|
-
"query": "",
|
46
|
-
"launchMode": "default",
|
47
|
-
"scene": null
|
48
|
-
}
|
49
|
-
]
|
50
|
-
}
|
51
|
-
},
|
52
|
-
"compileType": "miniprogram",
|
53
|
-
"libVersion": "2.28.0",
|
54
|
-
"packOptions": {
|
55
|
-
"ignore": [],
|
56
|
-
"include": []
|
57
|
-
},
|
58
|
-
"editorSetting": {
|
59
|
-
"tabIndent": "insertSpaces",
|
60
|
-
"tabSize": 2
|
61
|
-
}
|
1
|
+
{
|
2
|
+
"setting": {
|
3
|
+
"newFeature": true,
|
4
|
+
"urlCheck": true,
|
5
|
+
"es6": false,
|
6
|
+
"postcss": true,
|
7
|
+
"minified": false,
|
8
|
+
"checkSiteMap": false,
|
9
|
+
"autoAudits": false,
|
10
|
+
"coverView": true,
|
11
|
+
"lazyloadPlaceholderEnable": false,
|
12
|
+
"preloadBackgroundData": false,
|
13
|
+
"uglifyFileName": false,
|
14
|
+
"uploadWithSourceMap": true,
|
15
|
+
"enhance": false,
|
16
|
+
"useMultiFrameRuntime": true,
|
17
|
+
"showShadowRootInWxmlPanel": true,
|
18
|
+
"packNpmManually": false,
|
19
|
+
"packNpmRelationList": [],
|
20
|
+
"minifyWXSS": true,
|
21
|
+
"useStaticServer": true,
|
22
|
+
"showES6CompileOption": false,
|
23
|
+
"checkInvalidKey": true,
|
24
|
+
"babelSetting": {
|
25
|
+
"ignore": [],
|
26
|
+
"disablePlugins": [],
|
27
|
+
"outputPath": ""
|
28
|
+
},
|
29
|
+
"disableUseStrict": false,
|
30
|
+
"useCompilerPlugins": false,
|
31
|
+
"minifyWXML": true,
|
32
|
+
"compileHotReLoad": true,
|
33
|
+
"ignoreUploadUnusedFiles": false,
|
34
|
+
"condition": false
|
35
|
+
},
|
36
|
+
"appid": "wx74053e55da62dcd3",
|
37
|
+
"projectname": "mpxdemo",
|
38
|
+
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
39
|
+
"condition": {
|
40
|
+
"miniprogram": {
|
41
|
+
"list": [
|
42
|
+
{
|
43
|
+
"name": "服务端下发",
|
44
|
+
"pathName": "pages/server-scheme",
|
45
|
+
"query": "",
|
46
|
+
"launchMode": "default",
|
47
|
+
"scene": null
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
51
|
+
},
|
52
|
+
"compileType": "miniprogram",
|
53
|
+
"libVersion": "2.28.0",
|
54
|
+
"packOptions": {
|
55
|
+
"ignore": [],
|
56
|
+
"include": []
|
57
|
+
},
|
58
|
+
"editorSetting": {
|
59
|
+
"tabIndent": "insertSpaces",
|
60
|
+
"tabSize": 2
|
61
|
+
}
|
62
62
|
}
|
package/vue.config.js
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
const { defineConfig } = require('@vue/cli-service')
|
2
|
-
const path = require('path')
|
3
|
-
module.exports = defineConfig({
|
4
|
-
pluginOptions: {
|
5
|
-
mpx: {
|
6
|
-
srcMode: 'wx',
|
7
|
-
plugin: {
|
8
|
-
customOutputPath(type, name, hash, ext) {
|
9
|
-
// console.log(1111, path.join(type + 's', name, 'index' + ext))
|
10
|
-
return path.join(type + 's', name, 'index' + ext)
|
11
|
-
}
|
12
|
-
},
|
13
|
-
loader: {}
|
14
|
-
}
|
15
|
-
}
|
16
|
-
})
|
1
|
+
const { defineConfig } = require('@vue/cli-service')
|
2
|
+
const path = require('path')
|
3
|
+
module.exports = defineConfig({
|
4
|
+
pluginOptions: {
|
5
|
+
mpx: {
|
6
|
+
srcMode: 'wx',
|
7
|
+
plugin: {
|
8
|
+
customOutputPath(type, name, hash, ext) {
|
9
|
+
// console.log(1111, path.join(type + 's', name, 'index' + ext))
|
10
|
+
return path.join(type + 's', name, 'index' + ext)
|
11
|
+
}
|
12
|
+
},
|
13
|
+
loader: {}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
})
|