This commit is contained in:
parent
0ed0867862
commit
44841f38e0
|
|
@ -14,7 +14,7 @@
|
||||||
"cropperjs": "1.5.12",
|
"cropperjs": "1.5.12",
|
||||||
"crypto-js": "4.1.1",
|
"crypto-js": "4.1.1",
|
||||||
"echarts": "5.1.2",
|
"echarts": "5.1.2",
|
||||||
"element-plus": "1.1.0-beta.8",
|
"element-plus": "1.1.0-beta.17",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"sortablejs": "1.14.0",
|
"sortablejs": "1.14.0",
|
||||||
"tinymce": "5.9.0",
|
"tinymce": "5.9.0",
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,16 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-form ref="form" :model="form" :label-width="config.labelWidth || '100px'" :label-position="config.labelPosition">
|
<el-skeleton v-if="loading || Object.keys(form).length==0" animated />
|
||||||
|
|
||||||
|
<el-form v-else ref="form" :model="form" label-width="130px" :label-position="config.labelPosition">
|
||||||
<el-row :gutter="15">
|
<el-row :gutter="15">
|
||||||
<template v-for="(item, index) in config.formItems" :key="index">
|
<template v-for="(item, index) in config.formItems" :key="index">
|
||||||
<el-col :span="item.span || 24" v-if="!hideHandle(item)">
|
<el-col :span="item.span || 24" v-if="!hideHandle(item)">
|
||||||
<el-form-item :label="item.label" :prop="item.name" :rules="rulesHandle(item)">
|
<el-form-item :label="item.label" :prop="item.name" :rules="rulesHandle(item)">
|
||||||
<!-- input -->
|
<!-- input -->
|
||||||
<template v-if="item.component=='input'" >
|
<template v-if="item.component=='input'" >
|
||||||
<el-input v-model="form[item.name]" :placeholder="item.options.placeholder" clearable></el-input>
|
<el-input v-model="form[item.name]" :placeholder="item.options.placeholder" clearable :maxlength="item.options.maxlength" show-word-limit></el-input>
|
||||||
</template>
|
</template>
|
||||||
<!-- checkbox -->
|
<!-- checkbox -->
|
||||||
<template v-else-if="item.component=='checkbox'" >
|
<template v-else-if="item.component=='checkbox'" >
|
||||||
|
|
@ -94,6 +96,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import http from "@/utils/request"
|
||||||
|
|
||||||
import { defineAsyncComponent } from 'vue';
|
import { defineAsyncComponent } from 'vue';
|
||||||
const inputRender = defineAsyncComponent(() => import('./items/input'));
|
const inputRender = defineAsyncComponent(() => import('./items/input'));
|
||||||
|
|
||||||
|
|
@ -119,7 +123,8 @@
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {}
|
form: {},
|
||||||
|
loading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
|
|
@ -128,10 +133,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.setForm()
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.setForm()
|
||||||
|
this.getData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
//构建form对象
|
//构建form对象
|
||||||
|
|
@ -160,6 +166,21 @@
|
||||||
this.form = this.deepMerge(this.form, this.modelValue)
|
this.form = this.deepMerge(this.form, this.modelValue)
|
||||||
//this.form = Object.assign({}, this.form, this.modelValue)
|
//this.form = Object.assign({}, this.form, this.modelValue)
|
||||||
},
|
},
|
||||||
|
getData() {
|
||||||
|
this.loading = true
|
||||||
|
var remoteData = []
|
||||||
|
this.config.formItems.forEach((item) => {
|
||||||
|
if(item.options && item.options.remote){
|
||||||
|
var req = http.get(item.options.remote.api, item.options.remote.data).then(res=>{
|
||||||
|
item.options.items = res.data
|
||||||
|
})
|
||||||
|
remoteData.push(req)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Promise.all(remoteData).then(()=>{
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
deepMerge(obj1, obj2) {
|
deepMerge(obj1, obj2) {
|
||||||
let key;
|
let key;
|
||||||
for (key in obj2) {
|
for (key in obj2) {
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@
|
||||||
<el-row :gutter="15">
|
<el-row :gutter="15">
|
||||||
<el-col :lg="6">
|
<el-col :lg="6">
|
||||||
<el-card shadow="never" header="1.参数配置">
|
<el-card shadow="never" header="1.参数配置">
|
||||||
<pre>{{config2}}</pre>
|
<pre>{{config3}}</pre>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="12">
|
<el-col :lg="12">
|
||||||
<el-card shadow="never" header="2.渲染器">
|
<el-card shadow="never" header="2.渲染器">
|
||||||
<sc-form :config="config2" v-model="data"></sc-form>
|
<sc-form :config="config3" v-model="data2"></sc-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card shadow="never" header="" v-if="false">
|
<el-card shadow="never" header="" v-if="false">
|
||||||
<el-form ref="formref" :model="d" label-width="100px" label-position="right" :rules="rules">
|
<el-form ref="formref" :model="d" label-width="100px" label-position="right" :rules="rules">
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="6">
|
<el-col :lg="6">
|
||||||
<el-card shadow="never" header="3.表单输出">
|
<el-card shadow="never" header="3.表单输出">
|
||||||
<pre>{{data}}</pre>
|
<pre>{{data2}}</pre>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
@ -55,7 +55,8 @@
|
||||||
{ required: true, message: '请输入活动名称', trigger: 'blur' }
|
{ required: true, message: '请输入活动名称', trigger: 'blur' }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
data: {
|
data: {},
|
||||||
|
data2: {
|
||||||
name: "Activity name",
|
name: "Activity name",
|
||||||
checkbox: {
|
checkbox: {
|
||||||
option1: true
|
option1: true
|
||||||
|
|
@ -64,7 +65,8 @@
|
||||||
select: ["1"],
|
select: ["1"],
|
||||||
select2: "1"
|
select2: "1"
|
||||||
},
|
},
|
||||||
config2: {
|
config2: {},
|
||||||
|
config3: {
|
||||||
labelWidth: '130px',
|
labelWidth: '130px',
|
||||||
labelPosition: 'right',
|
labelPosition: 'right',
|
||||||
size: 'medium',
|
size: 'medium',
|
||||||
|
|
@ -76,6 +78,7 @@
|
||||||
value: "123",
|
value: "123",
|
||||||
component: "input",
|
component: "input",
|
||||||
options: {
|
options: {
|
||||||
|
maxlength: "20",
|
||||||
placeholder: "Activity name",
|
placeholder: "Activity name",
|
||||||
},
|
},
|
||||||
rules: [
|
rules: [
|
||||||
|
|
@ -90,6 +93,10 @@
|
||||||
component: "select",
|
component: "select",
|
||||||
span: 12,
|
span: 12,
|
||||||
options: {
|
options: {
|
||||||
|
remote: {
|
||||||
|
api: '/api/system/dic/get',
|
||||||
|
data: {name: 'a'}
|
||||||
|
},
|
||||||
multiple: true,
|
multiple: true,
|
||||||
items:[
|
items:[
|
||||||
{
|
{
|
||||||
|
|
@ -114,6 +121,10 @@
|
||||||
component: "select",
|
component: "select",
|
||||||
span: 12,
|
span: 12,
|
||||||
options: {
|
options: {
|
||||||
|
remote: {
|
||||||
|
api: '/api/system/dic/get',
|
||||||
|
data: {name: 'b'}
|
||||||
|
},
|
||||||
items:[
|
items:[
|
||||||
{
|
{
|
||||||
label: "选项1",
|
label: "选项1",
|
||||||
|
|
@ -219,7 +230,7 @@
|
||||||
{
|
{
|
||||||
label: "Radio",
|
label: "Radio",
|
||||||
name: "radio",
|
name: "radio",
|
||||||
value: "",
|
value: "1",
|
||||||
component: "radio",
|
component: "radio",
|
||||||
options: {
|
options: {
|
||||||
items:[
|
items:[
|
||||||
|
|
@ -384,7 +395,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// this.config2 = this.config3
|
||||||
|
// },1000)
|
||||||
|
// setTimeout(()=>{
|
||||||
|
// this.data = this.data2
|
||||||
|
// },1500)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onSubmit(){
|
onSubmit(){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue