Browse Source

完善功能

old
wangqing 5 years ago
parent
commit
c6acd5d27f
  1. BIN
      src/assets/images/appearset_bgc_big.png
  2. 9
      src/router/modules/root.js
  3. 201
      src/views/form/PreView.vue
  4. 139
      src/views/form/PreView1.vue
  5. 136
      src/views/form/ProjectForm.vue
  6. 153
      src/views/form/theme.vue
  7. 12
      src/views/home/HomeView.vue
  8. 12
      src/views/home/index.vue

BIN
src/assets/images/appearset_bgc_big.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

9
src/router/modules/root.js

@ -1,4 +1,9 @@
export default [ export default [
{
path: '/test',
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/test')
},
{ {
path: '/', path: '/',
meta: {requireLogin: false}, meta: {requireLogin: false},
@ -61,5 +66,9 @@ export default [
path: '/project/preview', path: '/project/preview',
meta: {requireLogin: false}, meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/form/PreView.vue') component: () => import(/* webpackChunkName: 'root' */ '@/views/form/PreView.vue')
}, {
path: '/project/view',
meta: {requireLogin: false},
component: () => import(/* webpackChunkName: 'root' */ '@/views/form/ProjectForm.vue')
} }
] ]

201
src/views/form/PreView.vue

@ -1,134 +1,107 @@
<template> <template>
<div class="preview-form"> <div class="preview-container">
<div class="" v-if="!formState"> <el-tabs type="card" v-if="projectConfig.projectKey">
<el-row type="flex" justify="center" align="middle"> <el-tab-pane>
<el-col :sm="{span:20}" :xs="{span:24,offset:0}" style="text-align: center"> <span slot="label"><i class="el-icon-mobile"></i>
<h4 class="form-name-text"> 手机
{{formConf.title}}</h4> </span>
</el-col> <div class="preview-layer">
</el-row> <div class="preview-bg"/>
<el-row type="flex" justify="center" align="middle"> <div class="preview-phone">
<el-col :sm="{span:20}" :xs="{span:24,offset:0}" style="text-align: center"> <iframe id="preview-html" name="preview-html" class="preview-html"
<p class="form-name-text"> frameborder="0"
{{formConf.description}} src="http://localhost:8888/#/project/view?key=ec4dfaab04a94608a972845a5a459d3e"
</p> />
</el-col> </div>
</el-row> </div>
<el-divider></el-divider> </el-tab-pane>
<parser v-if="formConf.fields.length" :form-conf="formConf" @submit="submitForm"/> <el-tab-pane>
</div> <span slot="label"><i class="el-icon-monitor"></i>
<div v-if="formState"> 电脑
<p style="text-align: center"> </span>
<i class="el-icon-check"/>您已完成本次问卷感谢您的帮助与支持</p> <project-form :projectConfig="projectConfig" />
</div> </el-tab-pane>
</el-tabs>
</div> </div>
</template> </template>
<script> <script>
import Parser from '@/components/parser/Parser' import ProjectForm from './ProjectForm'
import {dbDataConvertForItemJson} from '@/utils/convert'
// parsernpm使
// import Parser from 'form-gen-parser'
window.onload = function() {
document.addEventListener('touchstart', function(event) {
if (event.touches.length > 1) {
event.preventDefault()
}
})
document.addEventListener('gesturestart', function(event) {
event.preventDefault()
})
}
export default { export default {
components: { name: 'PreView',
Parser props: {
}, projectConfig: {
props: {},
data() {
return {
key2: +new Date(),
projectKey: '', projectKey: '',
formState: false,// headImgUrl: '',
formConf: { color: ''
fields: [],
__methods__: {
clickTestButton1() {
console.log(
`%c【测试按钮1】点击事件里可以访问当前表单:
1) formModel='formData', 所以this.formData可以拿到当前表单的model
2) formRef='elForm', 所以this.$refs.elForm可以拿到当前表单的ref(vue组件)
`,
'color:#409EFF;font-size: 15px'
)
console.log('表单的Model:', this.formData)
console.log('表单的ref:', this.$refs.elForm)
}
},
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: {}, data() {
watch: {}, return {}
created() {
this.formConf.size = window.innerWidth < 480 ? 'medium' : 'small'
}, },
mounted() { mounted() {
this.$api.get(`/user/project/query/details/${this.$route.query.key}`).then(res => { this.projectConfig = {
if (res.data) { headImgUrl: 'http://cdn1.wenjuan.com/appear-PC-防疫13.png',
let fields = res.data.projectItems.map(item => { projectKey: 'afd5c3562c924d20b7da67b1f192ce25'
return dbDataConvertForItemJson(item)
})
this.formConf.fields = fields
this.formConf.title = res.data.project.name
this.formConf.description = res.data.project.describe
}
})
this.projectKey = this.$route.query.key
},
methods: {
fillFormData(form, data) {
form.fields.forEach(item => {
const val = data[item.__vModel__]
if (val) {
item.__config__.defaultValue = val
}
})
},
submitForm(data) {
this.$api.post('/user/project/result/create', {'projectKey': this.projectKey, 'collectData': data}).then(res => {
this.formState = true
})
} }
},
components: {
ProjectForm
} }
} }
</script> </script>
<style lang="scss" scoped> <style scoped>
.preview-form {
margin: 15px auto; .preview-container {
width: 800px; margin: 0;
padding: 15px; padding: 0;
background-repeat: repeat; background-color: #f7f7f7;
background-color: rgba(229, 239, 247, 0.87);
} }
@media screen and (max-width: 750px) { /deep/ .el-tabs__header {
.preview-form { width: 300px;
margin: 0px; margin: 0 auto;
width: 93% !important; border: none;
background-color: white; }
}
/deep/ .el-tabs--card > .el-tabs__header .el-tabs__item {
background-color: white;
border: 1px solid white;
}
div.preview-layer {
width: 500px;
height: 100%;
margin: 10px auto;
right: 0;
text-align: center;
}
div.preview-layer .preview-bg {
width: 500px;
height: 100%;
margin: 20px auto;
z-index: 999;
opacity: 0.7;
}
div.preview-layer .preview-phone {
width: 372px;
height: 744px;
background: url('~@/assets/images/appearset_bgc_big.png');
background-size: 372px 744px;
z-index: 1000;
}
.preview-html {
width: 318px !important;
height: 568px !important;
margin: 74px 0 0;
border-radius: 5px;
outline: none;
background-color: #fff;
} }
</style> </style>

139
src/views/form/PreView1.vue

@ -0,0 +1,139 @@
<template>
<div class="preview-form">
<div class="" v-if="!formState">
<el-row type="flex" justify="center" align="middle">
<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>
<el-row type="flex" justify="center" align="middle">
<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 v-if="formState">
<p style="text-align: center">
<i class="el-icon-check"/>您已完成本次问卷感谢您的帮助与支持</p>
</div>
</div>
</template>
<script>
import Parser from '@/components/parser/Parser'
import {dbDataConvertForItemJson} from '@/utils/convert'
// parsernpm使
// import Parser from 'form-gen-parser'
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: {
projectKey: ''
},
data() {
return {
key2: +new Date(),
projectKey: '',
formState: false,//
formConf: {
fields: [],
__methods__: {
clickTestButton1() {
console.log(
`%c【测试按钮1】点击事件里可以访问当前表单:
1) formModel='formData', 所以this.formData可以拿到当前表单的model
2) formRef='elForm', 所以this.$refs.elForm可以拿到当前表单的ref(vue组件)
`,
'color:#409EFF;font-size: 15px'
)
console.log('表单的Model:', this.formData)
console.log('表单的ref:', this.$refs.elForm)
}
},
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: {},
created() {
this.formConf.size = window.innerWidth < 480 ? 'medium' : 'small'
},
mounted() {
this.$api.get(`/user/project/query/details/${this.$route.query.key}`).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
this.formConf.description = res.data.project.describe
}
})
this.projectKey = this.$route.query.key
},
methods: {
fillFormData(form, data) {
form.fields.forEach(item => {
const val = data[item.__vModel__]
if (val) {
item.__config__.defaultValue = val
}
})
},
submitForm(data) {
this.$api.post('/user/project/result/create', {
'projectKey': this.projectKey,
'collectData': data
}).then(res => {
this.formState = true
})
}
}
}
</script>
<style lang="scss" scoped>
.preview-form {
margin: 15px auto;
width: 800px;
padding: 15px;
background-repeat: repeat;
background-color: rgba(229, 239, 247, 0.87);
}
@media screen and (max-width: 750px) {
.preview-form {
margin: 0px;
width: 93% !important;
background-color: white;
}
}
</style>

136
src/views/form/ProjectForm.vue

@ -0,0 +1,136 @@
<template>
<div class="project-form">
<div class="">
<el-image
:src="projectConfig.headImgUrl"
fit="scale-down"></el-image>
<el-row type="flex" justify="center" align="middle">
<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>
<el-row type="flex" justify="center" align="middle">
<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: {
headImgUrl: '',
color: '',
projectKey: '',
showBtn: false
}
},
data() {
return {
key2: +new Date(),
projectKey: '',
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: {},
created() {
//
if (!this.projectConfig) {
this.projectConfig = {
headImgUrl: '',
color: '',
projectKey: '',
showBtn: false
}
}
if (this.projectConfig && this.projectConfig.projectKey) {
this.projectKey = this.projectConfig.projectKey
} else if (this.$route.query.key) {
this.projectKey = this.$route.query.key
}
this.formConf.formBtns = this.projectConfig.showBtn
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
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>
<style lang="scss" scoped>
.project-form {
margin: 15px auto;
width: 800px;
padding: 15px;
background-repeat: repeat;
background-color: rgba(229, 239, 247, 0.87);
}
@media screen and (max-width: 750px) {
.project-form {
margin: 0px;
width: 93% !important;
background-color: white;
}
}
</style>

153
src/views/form/theme.vue

@ -1,42 +1,71 @@
<template xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html"> <template>
<div class="theme-container"> <div class="theme-container">
<el-row> <el-row>
<el-col :span="8" :offset="1"> <el-col :span="5" :offset="1">
<div class="left-container"> <el-scrollbar style="height: 77vh">
<p class="theme-title">外观主题</p> <div class="left-container">
<el-row> <p class="theme-title">外观主题</p>
<el-col :span="3"> <el-row>
<span class="theme-prompt-text">风格</span> <el-col :span="3">
</el-col> <span class="theme-prompt-text">风格</span>
<el-col :span="3" v-for="item in styleList"> </el-col>
<span class="style-btn">{{item.label}}</span> <el-col :span="3" v-for="item in styleList">
</el-col> <span
</el-row> :class="{'style-btn-active':activeStyle==item.key}"
<el-row> class="style-btn" @click="activeStyleHandler(item)">{{item.label}}</span>
<el-col :span="3"> </el-col>
<span class="theme-prompt-text">颜色</span> </el-row>
</el-col> <el-row>
<el-col v-bind:style="{backgroundColor: c}" class="color-btn" :span="3" v-for="c in colorList"> <el-col :span="3">
</el-col> <span class="theme-prompt-text">颜色</span>
</el-row> </el-col>
</div> <el-col :span="3">
<span
:class="{'style-btn-active':activeColor=''}"
class="style-btn" @click="activeColorHandler('')">全部</span>
</el-col>
<el-col
:class="{'style-btn-active':activeColor==c}"
@click.native="activeColorHandler(c)" v-bind:style="{backgroundColor: c}"
class="color-btn"
:span="3" v-for="c in colorList">
</el-col>
</el-row>
<el-row>
<el-col :span="8" v-for="t in themeList">
<el-image
class="head-list-img"
style="width: 100px; height: 100px"
:src="t.headImgUrl"
fit="cover"
></el-image>
</el-col>
</el-row>
</div>
</el-scrollbar>
</el-col> </el-col>
<el-col :span="8"> <el-col :offset="0" :span="12">
<pre-view :projectKey="projectKey"/>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="6">
外观设置 <div class="right-container"></div>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
<script> <script>
import PreView from './PreView'
export default { export default {
name: 'theme', name: 'theme',
components: {
PreView
},
data() { data() {
return { return {
styleList: [ styleList: [
{'label': '全部', 'key': ''},
{'label': '节日', 'key': 'festival'}, {'label': '节日', 'key': 'festival'},
{'label': '亲子', 'key': 'parent_child'}, {'label': '亲子', 'key': 'parent_child'},
{'label': '风景', 'key': 'scenery'}, {'label': '风景', 'key': 'scenery'},
@ -56,10 +85,35 @@ export default {
'#484848', '#484848',
'#EAEAEA', '#EAEAEA',
'#804000' '#804000'
] ],
activeColor: '',
activeStyle: '',
projectKey: '',
themeList: []
} }
}, methods: { },
tet() { mounted() {
this.projectKey = this.$route.query.key
this.queryProjectTheme()
},
methods: {
activeStyleHandler(item) {
this.activeStyle = item.key
this.queryProjectTheme()
},
activeColorHandler(item) {
this.activeColor = item
this.queryProjectTheme()
},
queryProjectTheme() {
this.$api.get('/project/theme/query', {
params: {
'color': this.activeColor,
'style': this.activeStyle
}
}).then(res => {
this.themeList = res.data
})
} }
} }
} }
@ -69,14 +123,15 @@ export default {
.theme-container { .theme-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow-y: hidden;
background-color: #f7f7f7; background-color: #f7f7f7;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
overflow: hidden;
} }
.left-container { .left-container {
width: 341px; width: 341px;
height: 845px; height: 70vh;
line-height: 20px; line-height: 20px;
border-radius: 7px; border-radius: 7px;
text-align: center; text-align: center;
@ -85,16 +140,15 @@ export default {
background-color: white; background-color: white;
} }
.style-btn { .style-btn {
line-height: 25px; line-height: 30px;
border-radius: 4px; border-radius: 4px;
padding: 2px; padding: 3px;
color: rgba(16, 16, 16, 100); color: #707070;
font-size: 14px; font-size: 14px;
margin: 3px; margin: 0 2px 4px 0;
text-align: center; //margin: 5px 9px; text-align: center; border: 1px solid #EAEAEA;
font-family: Arial;
border: 1px solid rgba(187, 187, 187, 100);
} }
.theme-title { .theme-title {
@ -106,8 +160,8 @@ export default {
.theme-prompt-text { .theme-prompt-text {
color: rgba(16, 16, 16, 100); color: rgba(16, 16, 16, 100);
font-size: 14px; font-size: 16px;
line-height: 20px; line-height: 30px;
text-align: left; text-align: left;
font-family: SourceHanSansSC-regular; font-family: SourceHanSansSC-regular;
} }
@ -129,5 +183,28 @@ export default {
.color-btn:hover, .color-btn:hover,
.style-btn:hover { .style-btn:hover {
cursor: pointer; cursor: pointer;
border: 1px solid rgba(11, 141, 213, 100);
}
.style-btn-active {
border: 1px solid rgba(11, 141, 213, 100);
}
.head-list-img {
border: 2px solid transparent;
}
.head-list-img:hover {
cursor: pointer;
border: 2px solid rgba(11, 141, 213, 100);
}
.right-container {
width: 456px;
height: 600px;
line-height: 20px;
text-align: center;
box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.4);
border: 1px solid rgba(255, 255, 255, 100);
} }
</style> </style>

12
src/views/home/HomeView.vue

@ -1,5 +1,17 @@
<template> <template>
<el-row> <el-row>
<!-- 轮播·1-->
<el-row>
<el-col :span="24">
<el-carousel height="55px">
<el-carousel-item v-for="item in 2" :key="item">
<img style="height: 55px; width: 100%;"
src="https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c4aj.png"
>
</el-carousel-item>
</el-carousel>
</el-col>
</el-row>
<Dashboard /> <Dashboard />
<HomeFunction /> <HomeFunction />
</el-row> </el-row>

12
src/views/home/index.vue

@ -33,18 +33,6 @@
</el-row> </el-row>
</el-header> </el-header>
<el-main style="padding: 2px;"> <el-main style="padding: 2px;">
<!-- 轮播·1-->
<el-row>
<el-col :span="24">
<el-carousel height="55px">
<el-carousel-item v-for="item in 2" :key="item">
<img style="height: 55px; width: 100%;"
src="https://freebrio.oss-cn-shanghai.aliyuncs.com/t/v2_q2c4aj.png"
>
</el-carousel-item>
</el-carousel>
</el-col>
</el-row>
<router-view /> <router-view />
</el-main> </el-main>
</el-container> </el-container>

Loading…
Cancel
Save