Skip to content

Commit

Permalink
动态Form
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Nov 1, 2018
1 parent 9b950e8 commit b9958d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 80 deletions.
84 changes: 11 additions & 73 deletions src/views/Archive/person.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
<div class="app-container" id="person">

<el-button @click="test()">测试保存表单</el-button>

<el-button @click="GetFormDetail()">获取person表单</el-button>
<br>
<generate-form
:data="jsonData"
ref="generateForm">
</generate-form>
<br>


<el-row>
Expand Down Expand Up @@ -128,82 +130,12 @@ import UploadAffix from "@/components/UploadAffix"
import {
GenerateForm
} from 'form-making'
import {GetFormDetail} from '@/api/system/form'
export default {
//
data() {
return {
jsonData:{
"list": [
{
"type": "input",
"name": "单行文本",
"icon": "regular/keyboard",
"options": {
"width": "100%",
"defaultValue": "",
"required": false,
"dataType": "string",
"pattern": "",
"placeholder": "",
"remoteFunc": "func_1540898325000_60519"
},
"key": "1540898325000_60519",
"model": "input_1540898325000_60519",
"rules": [
{
"type": "string",
"message": "单行文本格式不正确"
}
]
},
{
"type": "textarea",
"name": "多行文本",
"icon": "regular/keyboard",
"options": {
"width": "100%",
"defaultValue": "",
"required": false,
"pattern": "",
"placeholder": "",
"remoteFunc": "func_1540898327000_70367"
},
"key": "1540898327000_70367",
"model": "textarea_1540898327000_70367",
"rules": []
},
{
"type": "time",
"name": "时间选择器",
"icon": "regular/clock",
"options": {
"defaultValue": "",
"readonly": false,
"disabled": false,
"editable": true,
"clearable": true,
"placeholder": "",
"startPlaceholder": "",
"endPlaceholder": "",
"isRange": false,
"arrowControl": true,
"format": "HH:mm:ss",
"required": false,
"width": "",
"remoteFunc": "func_1540898328000_61326"
},
"key": "1540898328000_61326",
"model": "time_1540898328000_61326",
"rules": []
}
],
"config": {
"labelWidth": 100,
"labelPosition": "left",
"size": "small"
}
},
jsonData:null,
selected: null,
textMap: {
update: "编辑",
Expand Down Expand Up @@ -257,6 +189,12 @@ export default {
})
},
GetFormDetail(){
GetFormDetail("Person").then(res=>{
this.jsonData = JSON.parse(res.data.formJson)
})
},
handleSizeChange(val) {
this.listQuery.pageSize = val
this.fetchData(this.listQuery)
Expand Down
21 changes: 14 additions & 7 deletions src/views/system/formdesigner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<making-form preview generate-json ref="form">
<template slot="action">

<span style="margin-left:20px" v-if="selectform!==''">{{selectform}}</span>
<el-button style="border:none;float:left;margin-left:80px" @click="openmodal">选择要制作的表</el-button>
<span style="margin-left:20px;float:left" v-if="selectform!==''">正在制作:{{selectform}}</span>
<el-button style="border:none" @click="save"><svg-icon icon-class="icons"></svg-icon>
保存</el-button>
<el-button style="border:none;margin-right:0px" @click="openmodal"><svg-icon icon-class="icons"></svg-icon>
选择要制作的表</el-button>

<el-button style="border:none" @click="save">保存</el-button>
</template>
</making-form>

Expand Down Expand Up @@ -48,6 +50,7 @@ export default {
IsNew: true,
tablelist: null,
selectform: "",
ID:"",
dialogFormVisible: false
};
},
Expand All @@ -62,6 +65,7 @@ export default {
let json = this.$refs.form.getJSON()
console.log(json)
let obj = {
id:this.ID,
tableName: this.selectform,
formJson: json
}
Expand All @@ -77,18 +81,21 @@ export default {
},
select() {
GetFormDetail(this.selectform).then(res => {
if (res.code !== 400) {
this.dialogFormVisible = false;
console.log(res)
if (res.data!==null) {
this.$refs.form.setJSON(JSON.parse(res.data.formJson));
this.IsNew = false;
this.ID = res.data.id;
} else
{
this.$refs.form.setJSON([]);
this.$refs.form.setJSON({});
this.IsNew = true;
this.ID = ""
}
this.dialogFormVisible = false;
});
}
},
Expand Down

0 comments on commit b9958d0

Please sign in to comment.