BUG 26029

This commit is contained in:
aixianling
2021-12-24 22:45:52 +08:00
parent 33685758f3
commit 587dd3f899
7 changed files with 174 additions and 241 deletions

View File

@@ -1,775 +0,0 @@
<template>
<div class="add-form" v-if="pageShow">
<div v-show="!isShowConfig">
<div class="header-pic">
<image v-if="form.headPicture" :src="form.headPicture"/>
<span @click="upload">更换图片</span>
</div>
<div class="form-info">
<h2>文本选项</h2>
<div class="form-info__wrapper">
<textarea class="title" placeholder="请输入标题 (必填)" :maxlength="30" :auto-height="true"
v-model="form.title"></textarea>
<textarea
class="content"
border="none"
:clearable="false"
type="textarea"
v-model="form.tableExplain"
placeholder="请输入表单描述 (选填)"
:maxlength="255">
</textarea>
</div>
</div>
<draggable
class="components-list"
v-model="targetList"
:animation="340"
scroll
element="div"
:options="{
animation: 340,
handle: '.components-item__title'
}"
draggable=".components-item"
:sort="true">
<div class="components-item" v-for="(item, index) in targetList" :key="index"
@click="toFiledSetting(item, index)">
<div class="components-item__title">
<div class="components-item__title--left">
<em :style="{opacity: item.required ? 1 : 0}">*</em>
<i>{{ index + 1 }}.</i>
<h2>{{ item.label }}</h2>
</div>
<image :src="`${$cdn}askform/sc1.png`" @click.stop="removeComponent(index)"
@touchstart.stop="removeComponent(index)"/>
</div>
<div class="components-item__filed">
<template v-if="(item.type === 'radio')">
<u-radio-group v-model="item.value" wrap>
<u-radio class="u-radio" disabled style="display: block;" 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-radio>
</u-radio-group>
</template>
<template v-if="(item.type === 'checkbox')">
<u-checkbox-group v-model="item.value" wrap>
<u-checkbox class="u-checkbox" disabled :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>
</u-checkbox>
</u-checkbox-group>
</template>
<template v-if="(item.type === 'select')">
<div class="components-item__select">
<span>{{ 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 :src="`${$cdn}askform/upload.png`"/>
<span>选择图片10M以内</span>
</div>
</template>
<template v-if="(item.type === 'input')">
<div class="components-item__select">
<span>{{ item.placeholder }}</span>
</div>
</template>
<template v-if="(item.type === 'textarea')">
<div class="components-item__select components-item__textarea">
<span>{{ item.placeholder }}</span>
</div>
</template>
</div>
</div>
</draggable>
<div class="add-form__btn" @click="isShow = true">
<image :src="`${$cdn}askform/add.png`"/>
<span>添加问题</span>
</div>
<div class="add-form__footer">
<div class="add-form__footer--item-wrapper">
<div class="add-form__footer--item" @click="toPreview">
<image :src="`${$cdn}sass/preview.png`"/>
<span>预览</span>
</div>
<div class="add-form__footer--item" @click="toSetting">
<image :src="`${$cdn}sass/setting.png`"/>
<span>设置</span>
</div>
</div>
<div @click="onConfirm">立即发布</div>
</div>
<u-popup v-model="isShow" :closeable="false" mode="bottom" @close="isShow = false">
<div class="add-popup">
<div class="add-popup__title">
<h2>添加问题</h2>
<image :src="`${$cdn}askform/zk.png`" mode="aspectFit" @click="isShow = false"/>
</div>
<div class="add-popup__list">
<span @click="toFiledSetting('radio')">单选题</span>
<span @click="toFiledSetting('checkbox')">多选题</span>
<span @click="toFiledSetting('select')">单下拉框</span>
<span @click="toFiledSetting('input')">单行填空</span>
<span @click="toFiledSetting('textarea')">多行填空</span>
<span @click="toFiledSetting('upload')">上传图片</span>
</div>
</div>
</u-popup>
</div>
<div class="detail" v-if="isShowConfig">
<component
:is="component"
:index="filedIndex"
:filed="filed"
@change="onChange"
:targetListData="targetList"
:formData="form"
:filedType="filedType"
@back="isShowConfig = false"
:id="id"
:formConfig="formConfig">
</component>
</div>
</div>
</template>
<script>
import draggable from 'vuedraggable'
import FiledConfig from './FiledConfig'
import FormSetting from '../FormSetting'
import PreviewForm from './PreviewForm'
export default {
props: ['params'],
data() {
return {
pageShow: false,
isShowConfig: false,
form: {
tableExplain: '详细描述',
title: '问卷调查',
isShowheadPicture: true,
isShowTableExplain: true,
isShowBtn: true,
headPicture: '',
commitType: '1',
periodValidityType: '0',
actionNotice: '1',
dynamicNotice: '1',
periodValidityEndTime: '',
shareStatus: '0',
count: 0,
wechatId: '0',
type: 0,
buttonExplain: '提交',
tips: true
},
templateType: 0,
targetList: [],
isShow: false,
type: 0,
id: '',
filedType: '',
filed: {},
filedIndex: '',
isQuote: false,
touchStart: 0,
component: '',
formConfig: {}
}
},
components: {
draggable,
PreviewForm,
FormSetting,
FiledConfig
},
mounted() {
this.type = Number(this.params.type)
if (this.params.isQuote) {
this.isQuote = true
}
if (this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
} else {
this.pageShow = true
}
this.init()
uni.$on('setting', res => {
this.form = {
...this.form,
...res
}
this.formConfig = res
})
uni.$on('filedConfig', res => {
if (res.index === '-1') {
this.targetList.push(res.config)
} else {
this.$set(this.targetList, [res.index], res.config)
}
})
},
methods: {
toSetting() {
this.component = 'FormSetting'
this.isShowConfig = true
},
back() {
this.$emit('change', {
type: 'Tabbar'
})
},
onChange(e) {
},
removeComponent(index) {
this.targetList.splice(index, 1)
},
toPreview() {
this.component = 'PreviewForm'
this.isShowConfig = true
},
upload() {
let params = {
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
let count = this.fileList?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0)
if (count > 1) {
return this.$u.toast(`不能超过1个`)
}
if (res.tempFiles) {
res.tempFiles.map((item) => {
this.uploadFile(item)
})
} else if (res?.tempFile) {
this.uploadFile(res.tempFile)
}
}
}
uni.chooseImage(params)
},
uploadFile(img) {
uni.showLoading({title: '上传中'})
let formData = new FormData()
formData.append('file', img)
this.$http.post('/admin/file/add2', formData).then((res) => {
uni.hideLoading()
if (res?.data) {
this.$u.toast('上传成功!')
this.form.headPicture = res.data.url
}
}).catch(res => {
this.$u.toast(res)
uni.hideLoading()
})
},
onConfirm() {
for (let item of this.targetList) {
if (item.isShowPoints) {
if (item.pointType === '0') {
if (!item.answer || JSON.stringify(item.answer) === '[]') {
return this.$u.toast(`请输入${item.label}正确答案`)
}
if (!item.points) {
return this.$u.toast(`请输入${item.label}的分值`)
}
}
if (item.pointType === '1') {
for (let option of item.options) {
if (!option.point) {
return this.$u.toast(`请输入${item.label}${option.label}的分值`)
}
}
}
if (item.pointType === '2') {
for (let option of item.options) {
if (!option.point) {
return this.$u.toast(`请输入${item.label}${option.label}的分值`)
}
}
if (!item.points) {
return this.$u.toast(`请输入${item.label}全部答对分值`)
}
}
}
}
const fields = this.targetList.map(item => {
return {
fieldType: item.type,
fieldName: item.label,
fieldInfo: JSON.stringify(item)
}
})
this.$http.post(`/app/appquestionnairetemplate/addOrUpdate`, {
...this.form,
fields,
status: 1,
id: this.isQuote ? '' : this.id,
headPicture: this.form.headPicture,
type: this.type,
templateType: 0
}).then(res => {
if (res.code == 0) {
setTimeout(() => {
this.$emit('change', {
type: 'Result',
params: {
linkUrl: res.data.linkUrl,
title: this.form.title,
tableExplain: this.form.tableExplain,
headPicture: this.form.headPicture
}
})
}, 600)
}
}).catch(e => {
this.$u.toast(e)
})
},
getInfo(id) {
uni.showLoading()
this.$http.post(`/app/appquestionnairetemplate/queryDetailById?id=${id}`).then(res => {
if (res.code == 0) {
this.form = {
...res.data,
headPicture: res.data.headPicture
}
this.type = res.data.type
this.targetList = res.data.fields.map(item => {
return JSON.parse(item.fieldInfo)
})
this.pageShow = true
} else {
this.$u.toast(res.msg)
}
uni.hideLoading()
}).catch(() => {
uni.hideLoading()
})
},
toFiledSetting(type, index) {
this.isShow = false
if (index > -1) {
this.filed = type
this.filedIndex = index
this.component = 'FiledConfig'
this.isShowConfig = true
return false
}
this.filedIndex = ''
this.filedType = type
this.component = 'FiledConfig'
this.isShowConfig = true
},
init() {
if (this.type == 0) {
this.form.headPicture = 'https://cdn.cunwuyun.cn/dvcp/h5/form/interview.png'
}
if (this.type == 1) {
this.form.title = '考试测评'
this.form.headPicture = 'https://cdn.cunwuyun.cn/dvcp/h5/form/exam.png'
}
if (this.type == 2) {
this.form.title = '报名登记'
this.form.headPicture = 'https://cdn.cunwuyun.cn/dvcp/h5/form/apply.png'
}
if (this.type == 3) {
this.form.title = '满意调查'
this.form.headPicture = 'https://cdn.cunwuyun.cn/dvcp/h5/form/satisfaction.png'
}
if (this.type == 4) {
this.form.title = '投票评选'
this.form.headPicture = 'https://cdn.cunwuyun.cn/dvcp/h5/form/vote.png'
}
}
}
}
</script>
<style lang="scss" scoped>
.add-form {
min-height: 100vh;
padding-bottom: 140px;
box-sizing: border-box;
background: #F3F6F9;
* {
box-sizing: border-box;
}
.components-list {
padding: 0 20px;
.components-item {
margin-top: 24px;
padding: 32px;
box-shadow: 0 4px 8px 4px rgba(233, 233, 233, 0.39);
border-radius: 8px;
overflow: hidden;
border: 1px solid #EEEFF0;
background: #fff;
.u-checkbox, .u-radio {
display: block;
image {
width: 100px;
height: 100px;
margin: 0 10px;
}
}
::v-deep .u-radio, ::v-deep .u-checkbox {
position: relative;
margin-bottom: 20px;
&:last-child {
margin-bottom: 0;
}
.u-checkbox__icon-wrap, .u-radio__icon-wrap {
position: absolute;
top: 4px;
}
.u-radio__label, .u-checkbox__label {
display: flex;
align-items: center;
margin-right: 0;
margin-left: 40px;
text-align: justify;
span {
line-height: 1.5;
}
}
}
span {
flex: 1;
color: #666;
font-size: 26px;
}
.components-item__select {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 80px;
margin-bottom: 8px;
padding: 0 26px;
border: 1px solid #DEDFDF;
&.components-item__textarea {
align-items: flex-start;
height: 160px;
padding-top: 20px;
image {
width: 46px;
height: 34px;
margin-right: 16px;
}
span {
color: #666;
font-size: 26px;
}
}
&.components-item__upload {
justify-content: center;
align-items: center;
}
}
.components-item__title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 32px;
em {
margin-right: 4px;
font-style: normal;
color: rgb(226, 33, 32);;
}
image {
position: relative;
flex-shrink: 1;
right: -20px;
width: 32px;
height: 32px;
box-sizing: content-box;
padding: 30px 20px 30px 20px;
}
div {
display: flex;
align-items: baseline;
max-width: 550px;
color: #333333;
font-size: 32px;
i {
font-style: normal;
}
h2 {
font-weight: 600;
font-size: 32px;
}
}
}
}
}
.add-popup {
height: 440px;
border-radius: 20px 20px 0 0;
background: #fff;
.add-popup__title {
display: flex;
position: relative;
align-items: center;
justify-content: center;
height: 96px;
border-bottom: 1px solid #E4E5E6;
h2 {
color: #333333;
font-size: 32px;
font-weight: 600;
}
image {
position: absolute;
right: 32px;
top: 50%;
width: 30px;
height: 20px;
transform: translateY(-50%);
}
}
.add-popup__list {
display: flex;
flex-wrap: wrap;
padding: 0 34px;
span {
width: calc((100% - 64px) / 3);
height: 78px;
line-height: 78px;
margin-top: 32px;
margin-right: 32px;
text-align: center;
color: #333333;
font-size: 28px;
border-radius: 8px;
border: 1px solid #E4E5E6;
&:nth-of-type(3n) {
margin-right: 0;
}
}
}
}
.add-form__footer {
display: flex;
align-items: center;
position: fixed;
left: 0;
bottom: 0;
z-index: 1;
width: 100%;
height: 112px;
text-align: center;
& > div {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
height: 100%;
text-align: center;
background: #fff;
&:last-child {
color: #fff;
font-size: 36px;
background: #3192F4;
&:active {
opacity: 0.8;
}
}
span {
}
}
}
.add-form__footer--item-wrapper {
.add-form__footer--item {
display: flex;
align-items: center;
flex-direction: column;
flex: 1;
image {
display: block;
width: 48px;
height: 48px;
margin: 0 auto;
}
span {
display: block;
text-align: center;
color: #999;
font-size: 28px;
&:active {
background: #eee;
}
}
}
}
.add-form__btn {
display: flex;
align-items: center;
justify-content: center;
width: 214px;
height: 66px;
line-height: 66px;
margin: 64px auto 0;
background: #FFFFFF;
border-radius: 34px;
&:active {
opacity: 0.8;
}
image {
width: 28px;
height: 28px;
}
span {
margin-left: 16px;
color: #4392E6;
font-size: 28px;
}
}
* {
box-sizing: border-box;
}
.form-info {
padding: 0 20px;
& > h2 {
height: 76px;
line-height: 76px;
color: #999999;
font-weight: normal;
font-size: 28px;
}
.form-info__wrapper {
padding: 0 18px;
background: #fff;
.title {
width: 100%;
padding: 22px 0;
font-size: 36px;
border-bottom: 1px solid #F1F2F3;
}
.content {
width: 100%;
padding: 30px 0 !important;
color: #333;
font-size: 28px !important;
}
}
}
.header-pic {
position: relative;
font-size: 0;
span {
position: absolute;
bottom: 16px;
right: 16px;
z-index: 1;
width: 148px;
height: 56px;
line-height: 56px;
text-align: center;
color: #fff;
font-size: 26px;
background: rgba(0, 0, 0, 0.16);
border-radius: 28px;
}
image {
width: 100%;
height: 320px;
}
}
::v-deep .u-radio, ::v-deep .u-checkbox {
align-items: baseline;
}
}
</style>

View File

@@ -26,6 +26,8 @@
</template>
<script>
import qs from "query-string"
export default {
name: 'addList',
label: '新建项目',
@@ -47,30 +49,16 @@ export default {
}
},
mounted() {
created() {
this.getList()
},
methods: {
toAdd(type) {
this.$emit('change', {
type: 'AddForm',
params: {
type
}
})
uni.navigateTo({url: `./AddForm?${qs.stringify({type})}`})
},
quote(id) {
this.$emit('change', {
type: 'AddForm',
params: {
id,
isQuote: 1
}
})
uni.navigateTo({url: `./AddForm?${qs.stringify({id, isQuote: 1})}`})
},
getList() {
this.$http.post(`/app/appquestionnairetemplate/list`, null, {
params: {
@@ -79,7 +67,7 @@ export default {
size: 10000
}
}).then(res => {
if (res.code == 0) {
if (res?.code == 0) {
this.list = res.data.records
}
})

View File

@@ -1,547 +0,0 @@
<template>
<div class="form-config">
<div class="config-group">
<div class="config-item">
<u-input class="form-maintitle" :maxlength="200" v-model="config.label"
:placeholder="`请输入${config.fixedLabel||''}标题 ${config.required ? '(必填)' : ''}`"
placeholder-style="color: #999999; font-weight: 600"/>
</div>
<div class="config-item__select--wrapper" v-if="['radio', 'select', 'checkbox'].includes(config.type)">
<div class="config-item__select" v-for="(item, index) in config.options" :key="index">
<image class="config-icon" :src="`${$cdn}askform/del.png`" @click="removeOptions(index)"/>
<div class="config-item__upload" v-if="config.type !== 'select'" @click="upload(index)">
<u-icon color="#8c9dc3" name="plus" v-if="!item.img.length"></u-icon>
<image v-else :src="item.img[0].url"/>
</div>
<div class="textarea">
<textarea type="textarea" placeholder-style="color: #CDCDCF" :auto-height="true" v-model="item.label"
:maxlength="100" placeholder="请输入选项"/>
</div>
</div>
<div class="config-item__select config-item__select--add" @click="addOptions">
<image class="config-icon" :src="`${$cdn}askform/zj.png`"/>
<span>添加选项</span>
</div>
</div>
</div>
<div class="config-group">
<div class="config-item" v-if="!['radio', 'upload', 'checkbox', 'select'].includes(config.type)">
<div class="config-item__left">
<span>说明文字</span>
</div>
<div class="config-item__right">
<u-input v-model="config.placeholder" placeholder="请输入说明文字" input-align="right"/>
</div>
</div>
<div class="config-item">
<div class="config-item__left">
<span>是否必填</span>
</div>
<div class="config-item__right">
<u-switch v-model="config.required" active-value="1" inactive-value="0" :size="40"
active-color="#1088F9"></u-switch>
</div>
</div>
<div class="config-item" v-if="!['upload'].includes(config.type)">
<div class="config-item__left">
<span>答案与分值</span>
</div>
<div class="config-item__right">
<u-switch v-model="config.isShowPoints" :size="40" active-color="#1088F9"></u-switch>
</div>
</div>
<div class="config-item" v-if="['input', 'textarea'].includes(config.type) && config.isShowPoints">
<div class="config-item__left">
<span>正确答案</span>
</div>
<div class="config-item__right">
<u-input v-model="config.answer" placeholder="请输入正确答案" input-align="right"/>
</div>
</div>
<div class="config-item"
v-if="['radio', 'select'].includes(config.type) && config.isShowPoints && config.pointType === '0'">
<div class="config-item__left">
<span>正确答案</span>
</div>
<div class="config-item__right config-item__text" @click="isShowAnswer = true">
<span>{{ config.answer ? config.answer : '请选择正确答案' }}</span>
<u-icon name="arrow-down-fill" color="#c0c4cc" size="24"></u-icon>
</div>
</div>
<div class="config-item config-item__checkbox"
v-if="config.isShowPoints && ['radio', 'select', 'checkbox'].includes(config.type)">
<div class="config-item__left">
<span>计分方式</span>
</div>
<div class="config-item__right" @click="isShowType = true">
<span>{{ pointTypeName ? pointTypeName : '请选择' }}</span>
<u-icon name="arrow-right" color="#E1E2E3"/>
</div>
</div>
<div class="config-item config-item__answer config-item__checkbox"
v-if="['checkbox'].includes(config.type) && config.isShowPoints && config.pointType === '0'">
<div class="config-item__left">
<span>正确答案</span>
</div>
<div class="config-item__right">
<u-checkbox-group wrap @change="onCheckboxChange">
<u-checkbox v-model="field.checked" :name="field.label" v-if="field.label"
v-for="(field, i) in config.options" :key="i">
<span>{{ field.label }}</span>
</u-checkbox>
</u-checkbox-group>
</div>
</div>
<div class="config-item" v-if="config.isShowPoints && config.pointType === '0'">
<div class="config-item__left">
<span>本题分值</span>
</div>
<div class="config-item__right">
<u-input v-model="config.points" type="number" placeholder="请输入本题分值" input-align="right"/>
</div>
</div>
<div v-if="config.isShowPoints && config.pointType === '1'">
<div class="config-item" v-for="(item, index) in config.options" :key="index">
<div class="config-item__left">
<span>{{ item.label }}</span>
</div>
<div class="config-item__right">
<u-input v-model="item.point" placeholder="请输入分值" input-align="right"/>
</div>
</div>
</div>
<div class="config-item config-item__point" v-if="config.isShowPoints && config.pointType === '2'">
<u-checkbox-group wrap @change="onCheckboxChange">
<u-checkbox v-model="field.checked" :name="field.label" v-if="field.label"
v-for="(field, i) in config.options" :key="i">
<span>{{ field.label }}</span>
<u-input v-model="field.point" type="number" placeholder="请输入分值" input-align="right"/>
</u-checkbox>
</u-checkbox-group>
</div>
<div class="config-item" v-if="config.isShowPoints && config.pointType === '2'">
<div class="config-item__left" style="padding-left: 20px">
<span>全部答对</span>
</div>
<div class="config-item__right">
<u-input v-model="config.points" type="number" placeholder="请输入全部答对分值" input-align="right"/>
</div>
</div>
</div>
<u-select :list="config.options" :default-value="defaultAnswer" value-name="value" label-name="label"
v-model="isShowAnswer" @confirm="answerChange"></u-select>
<u-select :list="config.pointDict" :default-value="defaultType" value-name="dictValue" label-name="dictName"
v-model="isShowType" @confirm="pointTypeChange"></u-select>
<div class="add-form__footer">
<div @click="back">
<span>取消</span>
</div>
<div @click="confirm">确定</div>
</div>
</div>
</template>
<script>
import {components} from './config'
export default {
props: ['filed', 'index', 'filedType'],
data() {
return {
isShowType: false,
isShowAnswer: false,
config: {}
}
},
mounted() {
if (this.index !== '') {
this.config = this.filed
return false
}
console.log(components)
this.config = JSON.parse(JSON.stringify(components.filter(v => v.type === this.filedType)[0]))
},
computed: {
pointTypeName() {
if (!this.config.pointDict) return ''
return this.config.pointDict.filter(v => v.dictValue === this.config.pointType)[0].dictName
},
defaultType() {
if (!this.config.pointType) return [0]
return [Number(this.config.pointType)]
},
defaultAnswer() {
if (!this.config.answer) return [0]
let index = 0
if (this.config.answer) {
this.config.options?.forEach((v, i) => {
if (v.label === this.config.answer) {
index = i
}
})
}
return [index]
}
},
methods: {
answerChange(e) {
this.config.answer = e[0].label
},
pointTypeChange(e) {
console.log(e)
this.config.pointType = e[0].value
},
onCheckboxChange(e) {
this.config.answer = e
},
upload(index) {
let params = {
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
let count = this.fileList?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0)
if (count > 1) {
return this.$u.toast(`不能超过1个`)
}
if (res.tempFiles) {
res.tempFiles.map((item) => {
this.uploadFile(item, index)
})
}
}
}
uni.chooseImage(params)
},
uploadFile(img, index) {
uni.showLoading({title: '上传中'})
let formData = new FormData()
formData.append('file', img)
this.$http.post('/admin/file/add2', formData).then((res) => {
uni.hideLoading()
if (res?.data) {
this.$u.toast('上传成功!')
this.$set(this.config.options[index], 'img', [res.data])
}
}).catch(res => {
this.$u.toast(res)
uni.hideLoading()
})
},
removeOptions(index) {
const len = this.config.options.length
const label = this.config.options[index].label
if (len === 2) {
return this.$u.toast('选项不能少于2个')
}
if (this.config.type === 'checkbox') {
const answerIndex = this.config.answer.indexOf(label)
if (answerIndex > -1) {
this.config.answer.splice(answerIndex, 1)
}
} else {
if (label === this.config.answer) {
this.config.answer = ''
}
}
this.config.options.splice(index, 1)
},
back() {
this.$emit('back')
},
confirm() {
uni.$emit('filedConfig', {
config: this.config,
index: this.index === '' ? '-1' : this.index
})
this.back()
},
addOptions() {
const len = this.config.options.length
let label = `选项${len + 1}`
const index = this.config.options.findIndex(v => label === v.label)
if (index > -1) {
label = `新选项${len + 1}`
}
this.config.options.push({
label: label,
value: '',
point: '',
img: '',
checked: false
})
},
}
}
</script>
<style lang="scss" scoped>
.form-config {
box-sizing: border-box;
padding-bottom: 130px;
.form-maintitle {
::v-deep .uni-input-input {
font-size: 36px;
font-weight: 600;
}
}
.config-item__select--wrapper {
.config-item__select {
display: flex;
align-items: center;
::v-deep .u-input__input {
height: 100%;
}
.textarea {
flex: 1;
display: flex;
align-items: center;
min-height: 104px;
padding: 16px 0;
font-size: 28px;
border-bottom: 1px solid #dfe8f8;
}
textarea {
width: 100%;
font-size: 28px;
}
.config-icon {
width: 36px;
height: 36px;
margin-right: 12px;
}
}
.config-item__select--add {
height: 120px;
.config-icon {
margin-right: 18px;
}
span {
color: #1D74F4;
font-size: 30px;
}
}
}
.config-group {
margin-bottom: 32px;
padding: 0 32px;
background: #fff;
.config-item__upload {
display: flex;
align-items: center;
justify-content: center;
width: 60px;
height: 60px;
margin-right: 20px;
border: 1px solid rgb(208, 212, 220);
background-color: #fbfdff;
image {
width: 100%;
height: 100%;
}
}
.config-item {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 100px;
padding: 16px 0;
border-bottom: 1px solid #dfe8f8;
&:last-child {
border: none;
}
::v-deep .u-radio__label, ::v-deep .u-checkbox__label {
margin-right: 0;
font-size: 28px;
span {
max-width: 400 rpx;
line-height: 1.2;
}
}
.config-item__left {
max-width: 400px;
}
.config-item__right {
flex: 1;
text-align: right;
padding-left: 30px;
&.config-item__text {
display: flex;
align-items: center;
justify-content: flex-end;
span {
max-width: 400px;
margin-right: 10px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-break: keep-all;
}
}
.text {
}
}
&.config-item__answer {
display: block;
padding: 20px 0;
.config-item__left {
margin-bottom: 32 rpx;
span {
word-break: break-all;
color: #333;
font-size: 30px;
}
}
.config-item__right {
width: 100%;
padding-left: 0;
text-align: left;
}
}
}
::v-deep .u-checkbox {
align-items: baseline;
}
.config-item__checkbox {
height: auto;
padding: 14px 0;
::v-deep .u-checkbox, ::v-deep .u-radio {
// justify-content: flex-end;
}
}
.config-item__point {
height: auto;
padding: 0;
::v-deep .u-checkbox {
justify-content: inherit;
min-height: 100px;
padding: 14px 0;
border-bottom: 1px solid #eee;
&:last-child {
border: none;
}
.u-checkbox__label {
display: flex;
align-items: center;
justify-content: space-between;
flex: 1;
margin-right: 0;
.u-input {
flex: 1;
max-width: 400px;
}
}
}
}
}
* {
box-sizing: border-box;
}
.add-form__footer {
display: flex;
align-items: center;
position: fixed;
left: 0;
bottom: 0;
z-index: 1;
width: 100%;
height: 112px;
text-align: center;
div {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
height: 100%;
text-align: center;
background: #fff;
&:first-child:active {
background: #eee;
}
&:last-child {
color: #fff;
font-size: 36px;
background: #3192F4;
&:active {
opacity: 0.8;
}
}
span {
flex: 1;
height: 100%;
line-height: 112px;
color: #333333;
font-size: 32px;
&:active {
background: #eee;
}
}
}
}
}
</style>

View File

@@ -1,457 +0,0 @@
<template>
<div class="add-form">
<div class="header-pic">
<image v-if="form.headPicture" :src="form.headPicture"/>
</div>
<div class="form-info">
<div class="form-info__wrapper">
<textarea class="title" :auto-height="true" disabled placeholder="请输入标题 (必填)" v-model="form.title"></textarea>
<u-input class="content" disabled :clearable="false" type="textarea" v-model="form.tableExplain"
placeholder="请输入表单描述 (选填)" :height="80" :auto-height="true" :maxlength="255"></u-input>
</div>
</div>
<div class="components-list">
<div class="components-item" v-for="(item, index) in targetList" :key="index">
<div class="components-item__title">
<div class="components-item__title--left">
<em :style="{opacity: item.required ? 1 : 0}">*</em>
<i>{{ index + 1 }}.</i>
<h2>{{ item.label }}</h2>
</div>
</div>
<div class="components-item__filed">
<template v-if="(item.type === 'radio')">
<u-radio-group v-model="item.value" 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>
</u-radio>
</u-radio-group>
</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">
<image :src="field.img[0].url" v-if="field.img.length"/>
<span>{{ field.label }}</span>
</u-checkbox>
</u-checkbox-group>
</template>
<template v-if="(item.type === 'select')">
<div class="components-item__select">
<span>{{ 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 :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>
</div>
</template>
<template v-if="(item.type === 'textarea')">
<div class="components-item__select components-item__textarea">
<span>{{ item.placeholder }}</span>
</div>
</template>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
props: ['formData', 'targetListData'],
data() {
return {
form: {
tableExplain: '详细描述',
title: '问卷调查',
isShowheadPicture: true,
isShowTableExplain: true,
isShowBtn: true,
headPicture: '',
commitType: '1',
periodValidityType: '0',
actionNotice: '1',
dynamicNotice: '1',
periodValidityEndTime: '',
shareStatus: '0',
count: 0,
wechatId: '0',
type: 0,
buttonExplain: '提交',
tips: true
},
templateType: 0,
targetList: [],
isShow: false,
type: 0,
id: '',
touchStart: 0
}
},
mounted() {
this.form = this.formData
this.targetList = this.targetListData
},
methods: {
getInfo(id) {
uni.showLoading()
this.$http.post(`/app/appquestionnairetemplate/queryDetailById?id=${id}`).then(res => {
if (res.code == 0) {
this.form = {
...res.data,
headPicture: res.data.headPicture
}
this.type = res.data.type
this.targetList = res.data.fields.map(item => {
return JSON.parse(item.fieldInfo)
})
this.pageShow = true
} else {
this.$u.toast(res.msg)
}
uni.hideLoading()
}).catch(() => {
uni.hideLoading()
})
}
}
}
</script>
<style lang="scss" scoped>
.add-form {
min-height: 100vh;
padding-bottom: 60px;
box-sizing: border-box;
background: #F3F6F9;
* {
box-sizing: border-box;
}
::v-deep .u-drawer-bottom {
background-color: transparent;
}
.components-list {
padding: 0 20px;
.components-item {
margin-top: 24px;
padding: 32px;
box-shadow: 0 4px 8px 4px rgba(233, 233, 233, 0.39);
border-radius: 8px;
overflow: hidden;
border: 1px solid #EEEFF0;
background: #fff;
::v-deep .u-radio, ::v-deep .u-checkbox {
position: relative;
margin-bottom: 20px;
&:last-child {
margin-bottom: 0;
}
.u-checkbox__icon-wrap, .u-radio__icon-wrap {
position: absolute;
top: 4px;
}
.u-radio__label, .u-checkbox__label {
display: flex;
align-items: center;
margin-right: 0;
margin-left: 40px;
line-height: 1.5;
text-align: justify;
image {
width: 100px;
height: 100px;
margin: 0 10px;
}
}
}
span {
flex: 1;
color: #666;
font-size: 26px;
}
.components-item__select {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 80px;
margin-bottom: 8px;
padding: 0 26px;
border: 1px solid #DEDFDF;
&.components-item__textarea {
align-items: flex-start;
height: 160px;
padding-top: 20px;
image {
width: 46px;
height: 34px;
margin-right: 16px;
}
span {
color: #666;
font-size: 26px;
}
}
&.components-item__upload {
justify-content: center;
align-items: center;
}
}
.components-item__title {
display: flex;
justify-content: space-between;
margin-bottom: 32px;
em {
margin-right: 4px;
font-style: normal;
color: rgb(226, 33, 32);;
}
image {
width: 32px;
height: 32px;
box-sizing: content-box;
padding: 20px 0 20px 20px;
}
div {
display: flex;
align-items: baseline;
color: #333333;
font-size: 32px;
i {
font-style: normal;
}
h2 {
font-weight: 600;
font-size: 32px;
}
}
}
}
}
.add-popup {
height: 440px;
border-radius: 20px 20px 0 0;
background: #fff;
.add-popup__title {
display: flex;
position: relative;
align-items: center;
justify-content: center;
height: 96px;
border-bottom: 1px solid #E4E5E6;
h2 {
color: #333333;
font-size: 32px;
font-weight: 600;
}
image {
position: absolute;
right: 32px;
top: 50%;
width: 30px;
height: 20px;
transform: translateY(-50%);
}
}
.add-popup__list {
display: flex;
flex-wrap: wrap;
padding: 0 34px;
span {
width: calc((100% - 64px) / 3);
height: 78px;
line-height: 78px;
margin-top: 32px;
margin-right: 32px;
text-align: center;
color: #333333;
font-size: 28px;
border-radius: 8px;
border: 1px solid #E4E5E6;
&:nth-of-type(3n) {
margin-right: 0;
}
}
}
}
.add-form__footer {
display: flex;
align-items: center;
position: fixed;
left: 0;
bottom: 0;
z-index: 1;
width: 100%;
height: 112px;
text-align: center;
div {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
height: 100%;
text-align: center;
background: #fff;
&:last-child {
color: #fff;
font-size: 36px;
background: #3192F4;
&:active {
opacity: 0.8;
}
}
span {
flex: 1;
height: 100%;
line-height: 112px;
color: #333333;
font-size: 32px;
&:active {
background: #eee;
}
}
}
}
.add-form__btn {
display: flex;
align-items: center;
justify-content: center;
width: 214px;
height: 66px;
line-height: 66px;
margin: 64px auto 0;
background: #FFFFFF;
border-radius: 34px;
&:active {
opacity: 0.8;
}
image {
width: 28px;
height: 28px;
}
span {
margin-left: 16px;
color: #4392E6;
font-size: 28px;
}
}
* {
box-sizing: border-box;
}
.form-info {
margin-top: 26px;
padding: 0 20px;
& > h2 {
height: 76px;
line-height: 76px;
color: #999999;
font-weight: normal;
font-size: 28px;
}
.form-info__wrapper {
padding: 0 18px;
background: #fff;
.title {
width: 100%;
padding: 22px 0;
font-size: 36px;
border-bottom: 1px solid #F1F2F3;
}
.content {
padding: 30px 0 !important;
font-size: 28px;
::v-deep textarea {
color: #333;
font-size: 28px !important;
}
}
}
}
.header-pic {
position: relative;
font-size: 0;
span {
position: absolute;
bottom: 16px;
right: 16px;
z-index: 1;
width: 148px;
height: 56px;
line-height: 56px;
text-align: center;
color: #fff;
font-size: 26px;
background: rgba(0, 0, 0, 0.16);
border-radius: 28px;
}
image {
width: 100%;
height: 320px;
}
}
}
</style>

View File

@@ -1,165 +0,0 @@
<template>
<div class="result">
<image class="result-success" :src="`${$cdn}form/result-success.png`"/>
<h2>创建成功</h2>
<p>表单创建成功您现在可以把表单分享给更多的好友来填写数据</p>
<div class="result-btn" @click="confirm">确定</div>
<div class="result-footer">
<div class="result-footer__item" @click="copy">
<div>
<image :src="`${$cdn}form/form-copylink.png`"/>
</div>
<h3>复制链接</h3>
</div>
<div class="result-footer__item" @click="shareWechat">
<div>
<image :src="`${$cdn}form/form-wechat.png`"/>
</div>
<h3>微信好友</h3>
</div>
<div class="result-footer__item" @click="share">
<div>
<image :src="`${$cdn}form/form-share.png`"/>
</div>
<h3>分享</h3>
</div>
</div>
</div>
</template>
<script>
import {mapActions} from 'vuex'
export default {
name: 'Result',
props: ['params'],
mounted() {
this.injectJWeixin(['sendChatMessage', 'selectEnterpriseContact'])
},
methods: {
...mapActions(['injectJWeixin', 'wxInvoke']),
copy() {
let oInput = document.createElement('input')
oInput.value = this.params.linkUrl
document.body.appendChild(oInput)
oInput.select()
document.execCommand('Copy')
this.$u.toast('已复制')
oInput.remove()
},
share() {
this.injectJWeixin(['shareAppMessage', 'shareWechatMessage']).then(() => {
this.wxInvoke(['shareAppMessage', {
title: this.params.title,
desc: this.params.tableExplain,
link: this.params.linkUrl,
imgUrl: this.params.headPicture
}])
})
},
shareWechat() {
this.injectJWeixin(['shareAppMessage', 'shareWechatMessage']).then(() => {
this.wxInvoke(['shareWechatMessage', {
title: this.params.title,
desc: this.params.tableExplain,
link: this.params.linkUrl,
imgUrl: this.params.headPicture
}])
})
},
confirm() {
this.$emit('change', {
type: 'Tabbar'
})
}
},
onShow() {
wx.hideOptionMenu();
}
}
</script>
<style lang="scss" scoped>
.result {
min-height: 100vh;
padding: 96px 96px 0;
text-align: center;
box-sizing: border-box;
background: #fff;
.result-footer {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 96px;
.result-footer__item {
flex: 1;
text-align: center;
div {
display: flex;
align-items: center;
justify-content: center;
width: 100px;
height: 100px;
margin: 0 auto 16px;
border-radius: 50%;
background: #F4F6FA;
image {
width: 100px;
height: 100px;
}
}
h3 {
color: #666666;
font-size: 24px;
font-weight: normal;
}
}
}
.result-success {
display: block;
width: 192px;
height: 192px;
margin: 0 auto 16px;
}
p {
margin: 16px 0 32px;
color: #999999;
font-size: 30px;
}
.result-btn {
width: 100%;
height: 88px;
line-height: 88px;
text-align: center;
font-size: 36px;
color: #fff;
background: #197DF0;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.02);
border-radius: 4px;
&:active {
opacity: 0.8;
}
}
h2 {
color: #333333;
font-size: 36px;
font-weight: 700;
}
}
</style>

View File

@@ -42,6 +42,14 @@ export default {
methods: {
onChange(e) {
this.$emit('change', e)
},
show() {
if (this.currIndex == 0) {
this.currIndex = -1
this.$nextTick(() => {
this.currIndex = 0
})
}
}
},
onReachBottom() {