动态表单
This commit is contained in:
parent
140a53a773
commit
5f6fa7ccc1
@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<div class="dynamicFroms">
|
||||
<div class="title flex between">
|
||||
<div><span style="color:#3F85FF;font-size: 12px;">|</span> 动态表单</div>
|
||||
<div class="">
|
||||
<el-button type="primary" @click="addFormInput" size="small">新增</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="formBox">
|
||||
<div class="formInput flex" v-for="(item, index) in dynamicFroms" :key="index">
|
||||
<input class="fromsTit" v-model="item.title" />
|
||||
<span style="padding:0 6px;">:</span>
|
||||
<el-input class="inputBox" :placeholder="'请输入' + item.title" v-model="item.value"></el-input>
|
||||
<div style="margin:0 12px;">
|
||||
<el-radio-group v-model="item.isRequired">
|
||||
<el-radio :label="true">必 填</el-radio>
|
||||
<el-radio :label="false">非必填</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<el-button type="text" @click="delectInput(index)" size="">删除</el-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dynamicFroms: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addFormInput() {
|
||||
this.dynamicFroms.push({
|
||||
title: '表单标题',
|
||||
name: '',
|
||||
isRequired: true,
|
||||
value: ''
|
||||
})
|
||||
},
|
||||
delectInput(i){
|
||||
this.dynamicFroms.splice(i,1);
|
||||
}
|
||||
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.dynamicFroms {
|
||||
margin-top: 20px;
|
||||
|
||||
.formBox {
|
||||
margin-top: 12px;
|
||||
|
||||
.inputBox {
|
||||
width: 200px !important;
|
||||
}
|
||||
|
||||
.formInput {
|
||||
.fromsTit {
|
||||
border: none;
|
||||
|
||||
border-bottom: 1px solid #E2E5EF;
|
||||
width: 120px;
|
||||
padding: 12px 6px;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.title {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.wrap {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
</style>
|
||||
@ -234,11 +234,15 @@
|
||||
</el-form-item>
|
||||
|
||||
</div>
|
||||
|
||||
<div
|
||||
id="container"
|
||||
style="width: 580px; height: 400px; background: pink"
|
||||
></div>
|
||||
<div class="addrTitle">{{ cardForm.addr }}</div>
|
||||
|
||||
<dynamicForms ref="dynamicFormsRef"></dynamicForms>
|
||||
|
||||
<div id="qrCode" ref="qrCodeDiv"></div>
|
||||
<div class="dialog-footer">
|
||||
<el-button
|
||||
@ -269,11 +273,13 @@ import {
|
||||
deletePointApi,
|
||||
} from "@/assets/js/api/insect.js";
|
||||
import { getProjectChilderSystemUserListApi } from "@/assets/js/api/configManage";
|
||||
import dynamicForms from "./components/dynamicForms/index.vue"
|
||||
// import QRCode from "qrcodejs2";
|
||||
var mouseTool;
|
||||
var mouseTool;
|
||||
var objs = [];
|
||||
export default {
|
||||
components:{dynamicForms},
|
||||
data() {
|
||||
return {
|
||||
searchForm: {
|
||||
@ -624,8 +630,12 @@ export default {
|
||||
},
|
||||
// 生成二维码
|
||||
addCardFn() {
|
||||
|
||||
this.$refs.cardForm.validate((valid) => {
|
||||
if (valid) {
|
||||
let formTemplate;
|
||||
formTemplate=this.$refs.dynamicFormsRef.dynamicFroms;
|
||||
|
||||
// 新增
|
||||
let data = this.cardForm;
|
||||
data.projectSn = this.$store.state.projectSn;
|
||||
@ -633,6 +643,7 @@ export default {
|
||||
data.createUserName = this.$store.state.userInfo.account;
|
||||
data.inspectUserIds = data.inspectUserIds.toString(',');
|
||||
data.noticeUserIds = data.noticeUserIds.toString(',');
|
||||
data.template=JSON.stringify(formTemplate);
|
||||
addPointApi(data).then((res) => {
|
||||
console.log("新增", res);
|
||||
if (res.code == 200) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user