You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
4.5 KiB

5 years ago
<template>
<div class="project-form">
<div class="">
<el-image
5 years ago
v-if="projectTheme.headImgUrl"
:src="projectTheme.headImgUrl"
5 years ago
fit="scale-down"></el-image>
5 years ago
<el-row v-if="projectTheme.showTitle" type="flex" justify="center" align="middle">
5 years ago
<el-col :sm="{span:20}" :xs="{span:24,offset:0}" style="text-align: center">
<h4 class="form-name-text">
{{formConf.title}}</h4>
</el-col>
</el-row>
5 years ago
<el-row v-if="projectTheme.showDescribe" type="flex" justify="center" align="middle">
5 years ago
<el-col :sm="{span:20}" :xs="{span:24,offset:0}" style="text-align: center">
<p class="form-name-text">
{{formConf.description}}
</p>
</el-col>
</el-row>
<el-divider>
</el-divider>
<parser v-if="formConf.fields.length" :form-conf="formConf" @submit="submitForm"/>
</div>
</div>
</template>
<script>
import Parser from '@/components/parser/Parser'
import {dbDataConvertForItemJson} from '@/utils/convert'
window.onload = function() {
document.addEventListener('touchstart', function(event) {
if (event.touches.length > 1) {
event.preventDefault()
}
})
document.addEventListener('gesturestart', function(event) {
event.preventDefault()
})
}
export default {
components: {
Parser
},
props: {
projectConfig: {
projectKey: '',
showBtn: false
}
},
data() {
return {
projectKey: '',
5 years ago
projectTheme: {
5 years ago
headImgUrl: '',
showTitle: true,
showDescribe: true
5 years ago
},
5 years ago
formConf: {
fields: [],
__methods__: {},
formRef: 'elForm',
formModel: 'formData',
size: 'small',
labelPosition: 'top',
labelWidth: 100,
formRules: 'rules',
gutter: 15,
disabled: false,
span: 24,
formBtns: true,
resetBtn: true,
unFocusedComponentBorder: true
}
}
},
computed: {},
watch: {},
5 years ago
beforeCreate() {
console.log( document.querySelector('body'))
document.querySelector('body').className = 'project-body'
},
5 years ago
created() {
5 years ago
5 years ago
if (this.projectConfig && this.projectConfig.projectKey) {
this.projectKey = this.projectConfig.projectKey
5 years ago
this.formConf.formBtns = this.projectConfig.showBtns
//不存去路由中尝试获取 ifreme
5 years ago
} else if (this.$route.query.key) {
this.projectKey = this.$route.query.key
5 years ago
this.formConf.formBtns = false
5 years ago
}
this.formConf.size = window.innerWidth < 480 ? 'medium' : 'small'
},
mounted() {
this.$api.get(`/user/project/query/details/${this.projectKey}`).then(res => {
if (res.data) {
let fields = res.data.projectItems.map(item => {
return dbDataConvertForItemJson(item)
})
this.formConf.fields = fields
this.formConf.title = res.data.project.name
5 years ago
if (res.data.userProjectTheme) {
5 years ago
this.projectTheme = res.data.userProjectTheme
}
5 years ago
this.formConf.description = res.data.project.describe
}
})
},
methods: {
submitForm(data) {
this.$api.post('/user/project/result/create', {
'projectKey': this.projectKey,
'collectData': data
}).then(res => {
this.formState = true
})
}
}
}
</script>
5 years ago
<style lang="scss" >
5 years ago
.project-form {
margin: 15px auto;
width: 800px;
padding: 15px;
background-repeat: repeat;
background-color: rgba(229, 239, 247, 0.87);
5 years ago
overflow: hidden;
}
.project-body::-webkit-scrollbar {
width: 0 !important;
background: transparent;
}
.project-body {
-ms-overflow-style: none;
}
.project-body {
overflow: -moz-scrollbars-none;
5 years ago
}
@media screen and (max-width: 750px) {
.project-form {
margin: 0px;
width: 93% !important;
background-color: white;
}
5 years ago
.project-form {
height: 100%;
width: 60vw;
}
5 years ago
}
</style>