问卷表单

This commit is contained in:
yanran200730
2022-02-07 13:52:43 +08:00
parent a0846e1f12
commit 7db3fdaf00
2 changed files with 116 additions and 46 deletions

View File

@@ -21,7 +21,7 @@
</div>
<div class="components-item__filed">
<template v-if="(item.type === 'radio')">
<u-radio-group v-model="item.value" wrap>
<u-radio-group :value="formInfo[`field_${index}`]" wrap>
<u-radio :name="field.label" v-for="(field, i) in item.options" :key="i">
<image :src="field.img[0].url" v-if="field.img.length"/>
<span>{{ field.label }}</span>
@@ -30,7 +30,7 @@
</template>
<template v-if="(item.type === 'checkbox')">
<u-checkbox-group wrap>
<u-checkbox :name="field.label" v-model="field.checked1" v-for="(field, i) in item.options" :key="i">
<u-checkbox :name="field.label" :value="formInfo[`field_${index}`].indexOf(field.label)" v-for="(field, i) in item.options" :key="i">
<image :src="field.img[0].url" v-if="field.img.length"/>
<span>{{ field.label }}</span>
</u-checkbox>
@@ -38,24 +38,25 @@
</template>
<template v-if="(item.type === 'select')">
<div class="components-item__select">
<span>{{ item.placeholder }}</span>
<span>{{ formInfo[`field_${index}`] || item.placeholder }}</span>
<u-icon name="arrow-down" color="#DEDFDF"/>
</div>
</template>
<template v-if="(item.type === 'upload')">
<div class="components-item__select components-item__textarea components-item__upload">
<image style="display: block; max-width: 100%;margin: 0 auto" v-if="formInfo[`field_${index}`]" :src="formInfo[`field_${index}`]" />
<div v-else class="components-item__select components-item__textarea components-item__upload">
<image :src="`${$cdn}askform/upload.png`"/>
<span>选择图片2M以内</span>
</div>
</template>
<template v-if="(item.type === 'input')">
<div class="components-item__select">
<span>{{ item.placeholder }}</span>
<span>{{ formInfo[`field_${index}`] || item.placeholder }}</span>
</div>
</template>
<template v-if="(item.type === 'textarea')">
<div class="components-item__select components-item__textarea">
<span>{{ item.placeholder }}</span>
<span>{{ formInfo[`field_${index}`]|| item.placeholder }}</span>
</div>
</template>
</div>
@@ -97,38 +98,28 @@ export default {
type: 0,
id: '',
touchStart: 0,
...params
...params,
formInfo: {}
}
},
mounted () {
onLoad (query) {
document.title = '表单预览'
query.id && this.getInfo(query.id, query.formId)
},
methods: {
getInfo(id) {
uni.showLoading()
this.$http.post(`/app/appquestionnairetemplate/queryDetailById?id=${id}`).then(res => {
getInfo(id, formId) {
this.$http.post(`/app/appquestionnairetemplate/queryDataInfoById?id=${formId}&dataId=${id}`).then(res => {
if (res.code == 0) {
this.form = {
...res.data,
headPicture: res.data.headPicture
}
this.formInfo = res.data
this.type = res.data.type
this.targetList = res.data.fields.map(item => {
return JSON.parse(item.fieldInfo)
this.targetList.forEach((item, index) => {
if (item.type === 'checkbox' && this.formInfo[`field_${index}`]) {
this.formInfo[`field_${index}`] = this.formInfo[`field_${index}`].split(',')
}
})
this.pageShow = true
} else {
this.$u.toast(res.msg)
}
uni.hideLoading()
}).catch(() => {
uni.hideLoading()
})
}
}